diff --git a/lib/delayed/backend/active_record.rb b/lib/delayed/backend/active_record.rb index 357fb196..a08a6853 100644 --- a/lib/delayed/backend/active_record.rb +++ b/lib/delayed/backend/active_record.rb @@ -62,7 +62,7 @@ def self.ready_to_run(worker_name, max_run_time) end def self.before_fork - if ::ActiveRecord.version >= Gem::Version.new('7.1.0') + if Gem::Version.new("7.1.0") <= ::ActiveRecord::VERSION::STRING ::ActiveRecord::Base.clear_all_connections!(:all) else ::ActiveRecord::Base.clear_all_connections! diff --git a/spec/helper.rb b/spec/helper.rb index 7ecbfc8e..4ac5fb9a 100644 --- a/spec/helper.rb +++ b/spec/helper.rb @@ -36,9 +36,9 @@ db_adapter ||= gemfile && gemfile[%r{gemfiles/(.*?)/}] && $1 # rubocop:disable Style/PerlBackrefs db_adapter ||= "sqlite3" -if db_adapter == "trilogy" && ActiveRecord.version < Gem::Version.new("7.1") - trilogy_adapter_gem = Gem::Specification.find_by_name("activerecord-trilogy-adapter").gem_dir - require "#{trilogy_adapter_gem}/lib/trilogy_adapter/connection" +puts "Testing with db adapter: #{defined?(Rails)}" +if db_adapter == "trilogy" && Gem::Version.new("7.1") > ActiveRecord::VERSION::STRING + require "trilogy_adapter/connection" ActiveSupport.on_load(:active_record) { extend TrilogyAdapter::Connection } end