Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions app/helpers/ops_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,19 @@ def row_data(label, value)
end

def database_details
@database_details = ActiveRecord::Base.configurations[Rails.env]
@database_details = ActiveRecord::Base.configurations.configs_for(:env_name => Rails.env).first.configuration_hash
@database_display_name =
if @database_details["host"].in?([nil, "", "localhost", "127.0.0.1"])
if @database_details[:host].in?([nil, "", "localhost", "127.0.0.1"])
_("Internal Database")
else
_("External Database")
end
@data = {:title => _('Basic Information')}
@data[:rows] = [
row_data(_('Name'), @database_display_name),
row_data(_('Hostname'), @database_details["host"]),
row_data(_('Database name'), @database_details["database"]),
row_data(_('Username'), @database_details["username"])
row_data(_('Hostname'), @database_details[:host]),
row_data(_('Database name'), @database_details[:database]),
row_data(_('Username'), @database_details[:username])
]
end

Expand Down
43 changes: 43 additions & 0 deletions cypress/e2e/ui/Settings/Application-Settings/diagnostics.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/* eslint-disable no-undef */

// Menu options
const SETTINGS_MENU_OPTION = 'Settings';
const APP_SETTINGS_MENU_OPTION = 'Application Settings';

// Accordion items
const DIAGNOSTICS_ACCORDION_ITEM = 'Diagnostics';
const MANAGEIQ_REGION_ACCORDION_ITEM = /^ManageIQ Region:/;

// Tab names
const DATABASE_TAB_LABEL = 'Database';

describe('Settings > Application Settings > Diagnostics', () => {
beforeEach(() => {
cy.login();
cy.menu(SETTINGS_MENU_OPTION, APP_SETTINGS_MENU_OPTION);
cy.accordion(DIAGNOSTICS_ACCORDION_ITEM);
});

describe('ManageIQ Region', () => {
beforeEach(() => {
cy.selectAccordionItem([MANAGEIQ_REGION_ACCORDION_ITEM]);
});

it('should navigate to the Database tab', () => {
// Intercept the API call when clicking on the Database tab
cy.interceptApi({
alias: 'getDatabaseTabInfo',
urlPattern: '/ops/change_tab?tab_id=diagnostics_database',
triggerFn: () => cy.tabs({ tabLabel: DATABASE_TAB_LABEL }),
});

// Verify the Database tab content is loaded
cy.get(`@getDatabaseTabInfo`).then((getCall) => {
expect(getCall.state).to.equal('Complete');
});

// Verify we're on the Database tab
cy.get('.tab-content').contains(DATABASE_TAB_LABEL).should('be.visible');
});
});
});
13 changes: 13 additions & 0 deletions spec/helpers/ops_helper_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
describe OpsHelper do
it "#database_details" do
db_config = ActiveRecord::Base.configurations.configs_for(:env_name => Rails.env).first.configuration_hash

expect(helper.database_details).to match_array(
[
{:cells => a_hash_including(:label => "Name", :value => a_string_matching(/ Database$/))},
{:cells => {:label => "Hostname", :value => db_config[:host]}},
{:cells => {:label => "Database name", :value => db_config[:database]}},
{:cells => {:label => "Username", :value => db_config[:username]}},
]
)
end

describe '#auth_mode_name' do
modes = %w[amazon httpd database]
modes_pretty = %w[Amazon External\ Authentication Database]
Expand Down