diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2e10af0..bf91dc1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,7 +13,7 @@ jobs: strategy: matrix: gemfile: [Gemfile, delayed.gemfile] - ruby-version: ['3.0', '3.1', '3.2'] + ruby-version: ['3.2', '3.3', '3.4'] env: BUNDLE_GEMFILE: ${{ matrix.gemfile }} steps: diff --git a/README.md b/README.md index fd2c230..6742e2f 100644 --- a/README.md +++ b/README.md @@ -179,5 +179,5 @@ jobs. ## License Delayed::Cron::Job is released under the terms of the MIT License. -Copyright 2014-2023 Pascal Zumkehr. See [LICENSE](LICENSE) for further +Copyright 2014-2025 Pascal Zumkehr. See [LICENSE](LICENSE) for further information. diff --git a/delayed.gemfile b/delayed.gemfile index fc4e6f6..a537916 100644 --- a/delayed.gemfile +++ b/delayed.gemfile @@ -1,5 +1,5 @@ source 'https://rubygems.org' -gem "delayed", "~> 0.4.0" +gem "delayed" gemspec diff --git a/spec/delayed_cron_job_spec.rb b/spec/delayed_cron_job_spec.rb index 3ac61ff..310f2c8 100644 --- a/spec/delayed_cron_job_spec.rb +++ b/spec/delayed_cron_job_spec.rb @@ -6,16 +6,6 @@ class TestJob def perform; end end - class DatabaseDisconnectPlugin < Delayed::Plugin - - callbacks do |lifecycle| - lifecycle.after(:perform) do - ActiveRecord::Base.connection.disconnect! - end - end - - end - before { Delayed::Job.delete_all } let(:cron) { '5 1 * * *' } @@ -182,11 +172,25 @@ class DatabaseDisconnectPlugin < Delayed::Plugin end context 'when database connection is lost' do + + class DatabaseDisconnectPlugin < Delayed::Plugin + callbacks do |lifecycle| + lifecycle.after(:perform) do + + pp ActiveRecord::Base.connection_pool.connections + ActiveRecord::Base.connection.disconnect! + end + end + end + around(:each) do |example| Delayed::Worker.plugins.unshift DatabaseDisconnectPlugin # hold onto a connection so the in-memory database isn't lost when disconnected temp_connection = ActiveRecord::Base.connection_pool.checkout + temp_connection.connect! + example.run + ActiveRecord::Base.connection_pool.checkin temp_connection Delayed::Worker.plugins.delete DatabaseDisconnectPlugin end