From 08f57bfb8f46e9f521b7d324fc47fe00d93f42bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Fri, 12 Oct 2012 14:42:26 -0300 Subject: Move the TestQueue tests to the proper file --- activesupport/test/queueing/test_queue_test.rb | 44 ++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'activesupport/test/queueing') 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 -- cgit v1.2.3