Skip to content

Commit

Permalink
add failing specs for scheduled jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
pik committed Aug 21, 2015
1 parent 7c0ff78 commit c95d5fb
Showing 1 changed file with 27 additions and 3 deletions.
30 changes: 27 additions & 3 deletions spec/lib/client/middleware_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,33 @@ def perform(_)
end

describe 'when a job is already scheduled' do
before { MyUniqueWorker.perform_in(3600, 1) }
it 'rejects new jobs with the same argument' do
expect(MyUniqueWorker.perform_async(1)).to eq(nil)
before 'schedule a job' do
MyUniqueWorker.perform_in(3600, 1)
end

context '#old_unique_for' do

it 'rejects new scheduled jobs with the same argument' do
allow(SidekiqUniqueJobs.config).to receive(:unique_storage_method).and_return(:old)
expect(MyUniqueWorker.perform_in(1800, 1)).to eq(nil)
end

it 'will run a job in real time with the same arguments' do
allow(SidekiqUniqueJobs.config).to receive(:unique_storage_method).and_return(:old)
expect(MyUniqueWorker.perform_async(1)).not_to eq(nil)
end
end
context '#new_unique_for' do

it 'rejects new scheduled jobs with the same argument' do
allow(SidekiqUniqueJobs.config).to receive(:unique_storage_method).and_return(:new)
expect(MyUniqueWorker.perform_in(3600, 1)).to eq(nil)
end

it 'will run a job in real time with the same arguments' do
allow(SidekiqUniqueJobs.config).to receive(:unique_storage_method).and_return(:new)
expect(MyUniqueWorker.perform_async(1)).not_to eq(nil)
end
end
end

Expand Down

0 comments on commit c95d5fb

Please sign in to comment.