Skip to content

Commit

Permalink
Merge pull request #877 from sharetribe/dont-mutate-opts
Browse files Browse the repository at this point in the history
Don't mutate the options hash
  • Loading branch information
albus522 committed Mar 31, 2017
2 parents ccbde3d + fd8ad9c commit 263123b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/delayed/backend/job_preparer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class JobPreparer
attr_reader :options, :args

def initialize(*args)
@options = args.extract_options!
@options = args.extract_options!.dup
@args = args
end

Expand Down
7 changes: 7 additions & 0 deletions lib/delayed/backend/shared_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,13 @@ def create_job(opts = {})
job = described_class.enqueue M::ModuleJob.new
expect { job.invoke_job }.to change { M::ModuleJob.runs }.from(0).to(1)
end

it 'does not mutate the options hash' do
options = { priority: 1}
job = described_class.enqueue SimpleJob.new, options
expect(options).to eq({ priority: 1 })
end

end

context 'with delay_jobs = false' do
Expand Down

0 comments on commit 263123b

Please sign in to comment.