Skip to content
This repository
Browse code

Merge pull request #6020 from 7even/test_queue_order

Rails::Queueing::TestQueue run order
  • Loading branch information...
commit 3ca7b137fbc7001a9b3384d2a44132913a93bb4b 2 parents 4dcaffb + 804db94
Aaron Patterson tenderlove authored
2  railties/lib/rails/queueing.rb
@@ -18,7 +18,7 @@ def drain
18 18 # run the jobs in a separate thread so assumptions of synchronous
19 19 # jobs are caught in test mode.
20 20 t = Thread.new do
21   - while job = @contents.pop
  21 + while job = @contents.shift
22 22 job.run
23 23 end
24 24 end
13 railties/test/queueing/test_queue_test.rb
@@ -25,6 +25,19 @@ def test_contents
25 25 assert_equal [job], @queue.contents
26 26 end
27 27
  28 + def test_order
  29 + time1 = time2 = nil
  30 +
  31 + job1 = Job.new(1) { time1 = Time.now }
  32 + job2 = Job.new(2) { time2 = Time.now }
  33 +
  34 + @queue.push job1
  35 + @queue.push job2
  36 + @queue.drain
  37 +
  38 + assert time1 < time2, "Jobs run in the same order they were added"
  39 + end
  40 +
28 41 def test_drain
29 42 t = nil
30 43 ran = false

0 comments on commit 3ca7b13

Please sign in to comment.
Something went wrong with that request. Please try again.