Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Move the TestQueue tests to the proper file

  • Loading branch information...
commit 08f57bfb8f46e9f521b7d324fc47fe00d93f42bf 1 parent d08b89f
@rafaelfranca rafaelfranca authored
View
44 activesupport/test/queueing/test_queue_test.rb
@@ -99,4 +99,48 @@ def test_drain
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
View
47 railties/test/application/queue_test.rb
@@ -69,45 +69,6 @@ def ran?
refute job.ran_in_different_thread?, "Expected job to run in the same thread"
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
-
- test "in test mode, the queue can be observed" do
- app("test")
-
- jobs = (1..10).map do |id|
- IdentifiableJob.new(id)
- end
-
- jobs.each do |job|
- Rails.queue.push job
- end
-
- assert_equal jobs, Rails.queue.jobs
- end
-
- test "in test mode, adding an unmarshallable job will raise an exception" do
- app("test")
- anonymous_class_instance = Struct.new(:run).new
- assert_raises TypeError do
- Rails.queue.push anonymous_class_instance
- end
- end
-
test "attempting to marshal a queue will raise an exception" do
app("test")
assert_raises TypeError do
@@ -115,14 +76,6 @@ def run
end
end
- test "attempting to add a reference to itself to the queue will raise an exception" do
- app("test")
- job = {reference: Rails.queue}
- assert_raises TypeError do
- Rails.queue.push job
- end
- end
-
def setup_custom_queue
add_to_env_config "production", <<-RUBY
require "my_queue"
Please sign in to comment.
Something went wrong with that request. Please try again.