Skip to content

Commit 468591a

Browse files
committed
Fix diagnostics database page
1 parent 9fb9287 commit 468591a

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

app/helpers/ops_helper.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,19 @@ def row_data(label, value)
2222
end
2323

2424
def database_details
25-
@database_details = ActiveRecord::Base.configurations[Rails.env]
25+
@database_details = ActiveRecord::Base.configurations.configs_for(:env_name => Rails.env).first.configuration_hash
2626
@database_display_name =
27-
if @database_details["host"].in?([nil, "", "localhost", "127.0.0.1"])
27+
if @database_details[:host].in?([nil, "", "localhost", "127.0.0.1"])
2828
_("Internal Database")
2929
else
3030
_("External Database")
3131
end
3232
@data = {:title => _('Basic Information')}
3333
@data[:rows] = [
3434
row_data(_('Name'), @database_display_name),
35-
row_data(_('Hostname'), @database_details["host"]),
36-
row_data(_('Database name'), @database_details["database"]),
37-
row_data(_('Username'), @database_details["username"])
35+
row_data(_('Hostname'), @database_details[:host]),
36+
row_data(_('Database name'), @database_details[:database]),
37+
row_data(_('Username'), @database_details[:username])
3838
]
3939
end
4040

spec/helpers/ops_helper_spec.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,17 @@
11
describe OpsHelper do
2+
it "#database_details" do
3+
db_config = ActiveRecord::Base.configurations.configs_for(:env_name => Rails.env).first.configuration_hash
4+
5+
expect(helper.database_details).to match_array(
6+
[
7+
{:cells => a_hash_including(:label => "Name", :value => a_string_matching(/ Database$/))},
8+
{:cells => {:label => "Hostname", :value => db_config[:host]}},
9+
{:cells => {:label => "Database name", :value => db_config[:database]}},
10+
{:cells => {:label => "Username", :value => db_config[:username]}},
11+
]
12+
)
13+
end
14+
215
describe '#auth_mode_name' do
316
modes = %w[amazon httpd database]
417
modes_pretty = %w[Amazon External\ Authentication Database]

0 commit comments

Comments
 (0)