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

Override global option with group option #822

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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 lib/whenever/job_list.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def job_type(name, template)

@jobs[options.fetch(:mailto)] ||= {}
@jobs[options.fetch(:mailto)][@current_time_scope] ||= []
@jobs[options.fetch(:mailto)][@current_time_scope] << Whenever::Job.new(@options.merge(@set_variables).merge(options))
@jobs[options.fetch(:mailto)][@current_time_scope] << Whenever::Job.new(@set_variables.merge(@options).merge(options))
end
end
end
Expand Down
28 changes: 28 additions & 0 deletions test/functional/output_defined_job_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,34 @@ class OutputDefinedJobTest < Whenever::TestCase
assert_match(/^.+ .+ .+ .+ before during after local$/, output)
end

test "defined job with a :task and an option where the option is set globally and on the group" do
output = Whenever.cron \
<<-file
set :job_template, nil
job_type :some_job, "before :task after :option1"
set :option1, 'global'
every 2.hours, :option1 => 'group' do
some_job "during"
end
file

assert_match(/^.+ .+ .+ .+ before during after group$/, output)
end

test "defined job with a :task and an option where the option is set globally, on the group, and locally" do
output = Whenever.cron \
<<-file
set :job_template, nil
job_type :some_job, "before :task after :option1"
set :option1, 'global'
every 2.hours, :option1 => 'group' do
some_job "during", :option1 => 'local'
end
file

assert_match(/^.+ .+ .+ .+ before during after local$/, output)
end

test "defined job with a :task and an option that is not set" do
output = Whenever.cron \
<<-file
Expand Down