Skip to content

Commit

Permalink
Drop support for EOL AR v6.1 (#178)
Browse files Browse the repository at this point in the history
  • Loading branch information
coding-chimp authored Feb 7, 2025
1 parent bde867e commit 59ec680
Show file tree
Hide file tree
Showing 7 changed files with 4 additions and 118 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
fail-fast: false
max-parallel: 8
matrix:
activerecord: ["6.1", "7.2", "8.0", "head"]
activerecord: ["7.2", "8.0", "head"]
ruby: ["3.1", "3.2", "3.3", "head"]
mysql: ["5.7", "8.0"]
adapter: ["mysql2", "trilogy"]
Expand Down
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.2.2
3.3.6
5 changes: 0 additions & 5 deletions Appraisals
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
appraise "activerecord-6.1" do
gem "activerecord", "6.1.0"
gem "activerecord-trilogy-adapter"
end

appraise "activerecord-7.2" do
gem "activerecord", "7.2.2.1"
end
Expand Down
8 changes: 0 additions & 8 deletions gemfiles/activerecord_6.1.gemfile

This file was deleted.

80 changes: 0 additions & 80 deletions gemfiles/activerecord_6.1.gemfile.lock

This file was deleted.

19 changes: 1 addition & 18 deletions lib/lhm/throttler/replica_lag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def prepare_connection_config(config_proc)
raise ArgumentError, "Expected #{config_proc.inspect} to respond to `call`"
end
else
db_config
ActiveRecord::Base.connection_pool.db_config.configuration_hash.dup
end
config.deep_symbolize_keys!
config[:host] = @host
Expand All @@ -147,23 +147,6 @@ def query_connection(query, result)
Lhm.logger.info "Unable to connect and/or query #{host}: #{e}"
[nil]
end

private

def db_config
if ar_supports_db_config?
ActiveRecord::Base.connection_pool.db_config.configuration_hash.dup
else
ActiveRecord::Base.connection_pool.spec.config.dup
end
end

def ar_supports_db_config?
# https://api.rubyonrails.org/v6.0/classes/ActiveRecord/ConnectionAdapters/ConnectionPool.html <-- has spec
# vs
# https://api.rubyonrails.org/v6.1/classes/ActiveRecord/ConnectionAdapters/ConnectionPool.html <-- has db_config
ActiveRecord::VERSION::MAJOR > 6 || ActiveRecord::VERSION::MAJOR == 6 && ActiveRecord::VERSION::MINOR >= 1
end
end
end
end
6 changes: 1 addition & 5 deletions spec/unit/throttler/replica_lag_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,7 @@
describe 'with active record config' do
it 'logs and creates client' do
active_record_config = { username: 'user', password: 'pw', database: 'db' }
if ActiveRecord::VERSION::MAJOR > 6 || ActiveRecord::VERSION::MAJOR == 6 && ActiveRecord::VERSION::MINOR >= 1
ActiveRecord::Base.stubs(:connection_pool).returns(stub(db_config: stub(configuration_hash: active_record_config)))
else
ActiveRecord::Base.stubs(:connection_pool).returns(stub(spec: stub(config: active_record_config)))
end
ActiveRecord::Base.stubs(:connection_pool).returns(stub(db_config: stub(configuration_hash: active_record_config)))

DATABASE.client.stubs(:new).returns(mock())

Expand Down

0 comments on commit 59ec680

Please sign in to comment.