Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DEV: Compatibility with Discourse on Rails 6.1 #21

Merged
merged 1 commit into from
Apr 21, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .discourse-compatibility
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.7.0.beta6: b3f511e1d2bcb7cedb0bf6c582efbda0a5488bd3
2 changes: 1 addition & 1 deletion lib/internal_metric/global.rb
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def primary_site_readonly?
end

def test_postgres(master: true)
config = ActiveRecord::Base.connection_config
config = ActiveRecord::Base.connection_db_config.configuration_hash

unless master
if config[:replica_host]
Expand Down
4 changes: 3 additions & 1 deletion spec/lib/internal_metric/global_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,14 @@ module DiscoursePrometheus::InternalMetric

describe 'when a replica has been configured' do
before do
config = ActiveRecord::Base.connection_config
config = ActiveRecord::Base.connection_db_config.configuration_hash.dup

config.merge!(
replica_host: 'localhost',
replica_port: 1111
)
ActiveRecord::Base.connection.disconnect!
ActiveRecord::Base.establish_connection(config)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a big fan of this, but Rails 6.1 freezes the connection config hash. I could cheat and use instance_variable_set to change the underlying hash object inside db_config, but that doesn't seem like a great solution either.

end

it 'should collect the right metrics' do
Expand Down