diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2012-10-12 14:42:26 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2012-10-12 14:42:26 -0300 |
commit | 08f57bfb8f46e9f521b7d324fc47fe00d93f42bf (patch) | |
tree | 647ca1dc43ff9a3af58c56272691e41a6c8a2ec4 /activesupport/test/queueing | |
parent | d08b89fa4b422c66b4e408d87e5d8e198299a2bd (diff) | |
download | rails-08f57bfb8f46e9f521b7d324fc47fe00d93f42bf.tar.gz rails-08f57bfb8f46e9f521b7d324fc47fe00d93f42bf.tar.bz2 rails-08f57bfb8f46e9f521b7d324fc47fe00d93f42bf.zip |
Move the TestQueue tests to the proper file
Diffstat (limited to 'activesupport/test/queueing')
-rw-r--r-- | activesupport/test/queueing/test_queue_test.rb | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/activesupport/test/queueing/test_queue_test.rb b/activesupport/test/queueing/test_queue_test.rb index e398a48bea..451fb68d3e 100644 --- a/activesupport/test/queueing/test_queue_test.rb +++ b/activesupport/test/queueing/test_queue_test.rb @@ -99,4 +99,48 @@ class TestQueueTest < ActiveSupport::TestCase assert job.ran?, "The job runs synchronously when the queue is drained" assert_equal job.thread_id, Thread.current.object_id end + + class IdentifiableJob + def initialize(id) + @id = id + end + + def ==(other) + other.same_id?(@id) + end + + def same_id?(other_id) + other_id == @id + end + + def run + end + end + + def test_queue_can_be_observed + jobs = (1..10).map do |id| + IdentifiableJob.new(id) + end + + jobs.each do |job| + @queue.push job + end + + assert_equal jobs, @queue.jobs + end + + def test_adding_an_unmarshallable_job + anonymous_class_instance = Struct.new(:run).new + + assert_raises TypeError do + @queue.push anonymous_class_instance + end + end + + def test_attempting_to_add_a_reference_to_itself + job = {reference: @queue} + assert_raises TypeError do + @queue.push job + end + end end |