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

Fix default engine cron value #1258

Merged
merged 4 commits into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
1 change: 0 additions & 1 deletion lib/good_job/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ class Engine < ::Rails::Engine
isolate_namespace GoodJob

config.good_job = ActiveSupport::OrderedOptions.new
config.good_job.cron = {}

initializer "good_job.logger" do |_app|
ActiveSupport.on_load(:good_job) do
Expand Down
37 changes: 37 additions & 0 deletions spec/lib/good_job/configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,43 @@
end
end

describe '#cron' do
let(:cron) { { some_task: { cron: "every day", class: "FooJob" } } }

before do
stub_const 'ENV', ENV.to_hash.except('GOOD_JOB_CRON')
allow(Rails.application.config).to receive(:good_job).and_return({})
end

it 'returns entries specified in options' do
configuration = described_class.new({ cron: cron })

expect(configuration.cron).to eq(cron)
end

it 'returns entries specified in rails config' do
allow(Rails.application.config).to receive(:good_job).and_return({ cron: cron })

configuration = described_class.new({})

expect(configuration.cron).to eq(cron)
end

it 'returns entries specified in ENV' do
stub_const 'ENV', ENV.to_hash.merge({ 'GOOD_JOB_CRON' => cron.to_json })

configuration = described_class.new({})

expect(configuration.cron).to eq(cron)
end

it 'returns an empty hash without any entry specified' do
configuration = described_class.new({})

expect(configuration.cron).to eq({})
end
end

describe '#enable_listen_notify' do
it 'defaults to true' do
configuration = described_class.new({})
Expand Down