Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
2 changes: 1 addition & 1 deletion delayed.gemfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
source 'https://rubygems.org'

gem "delayed", "~> 0.4.0"
gem "delayed"

gemspec
24 changes: 14 additions & 10 deletions spec/delayed_cron_job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 * * *' }
Expand Down Expand Up @@ -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
Expand Down
Loading