Skip to content

Commit

Permalink
Test scheduled jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
dixpac committed Oct 13, 2024
1 parent b86b3ee commit 631868d
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion spec/active_job_adapter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def perform(message)

it 'enqueus and executes the job' do
start_worker do
job = TestJob.perform_later('hello')
TestJob.perform_later('hello')
sleep 2
expect(JobBuffer.values).to eq(['hello'])
end
Expand All @@ -53,6 +53,22 @@ def perform(message)
end
end

it 'should not run job enqueued in the future' do
start_worker do
TestJob.set(wait: 5.seconds).perform_later('hello')
sleep 2
expect(JobBuffer.values.empty?).to eq true
end
end

it 'should run job enqueued in the future at the specified time' do
start_worker do
TestJob.set(wait: 5.seconds).perform_later('hello')
sleep 10
expect(JobBuffer.values).to eq(['hello'])
end
end

private
def start_worker(&)
thread = Thread.new { worker.start }
Expand Down

0 comments on commit 631868d

Please sign in to comment.