aboutsummaryrefslogtreecommitdiffstats
path: root/activejob
diff options
context:
space:
mode:
authorCristian Bica <cristian.bica@gmail.com>2014-08-16 00:02:06 +0300
committerCristian Bica <cristian.bica@gmail.com>2014-08-16 00:02:06 +0300
commit788aee5acf195d55914e086540f907d9291e9d24 (patch)
tree614c906eeb3f5eaec9d4ac170d105445b7fc5b73 /activejob
parentc2f1eca19409cbbe72bf89b2087b212341201aa1 (diff)
downloadrails-788aee5acf195d55914e086540f907d9291e9d24.tar.gz
rails-788aee5acf195d55914e086540f907d9291e9d24.tar.bz2
rails-788aee5acf195d55914e086540f907d9291e9d24.zip
Moved AR testing from using global variable to thread variable
Diffstat (limited to 'activejob')
-rw-r--r--activejob/test/cases/job_serialization_test.rb4
-rw-r--r--activejob/test/cases/logging_test.rb2
-rw-r--r--activejob/test/cases/queuing_test.rb10
-rw-r--r--activejob/test/cases/rescue_test.rb4
-rw-r--r--activejob/test/jobs/gid_job.rb4
-rw-r--r--activejob/test/jobs/hello_job.rb2
-rw-r--r--activejob/test/jobs/rescue_job.rb4
7 files changed, 15 insertions, 15 deletions
diff --git a/activejob/test/cases/job_serialization_test.rb b/activejob/test/cases/job_serialization_test.rb
index b1e24db22e..f3b89d8899 100644
--- a/activejob/test/cases/job_serialization_test.rb
+++ b/activejob/test/cases/job_serialization_test.rb
@@ -4,12 +4,12 @@ require 'models/person'
class JobSerializationTest < ActiveSupport::TestCase
setup do
- $BUFFER = []
+ Thread.current[:ajbuffer] = []
@person = Person.find(5)
end
test 'serialize job with gid' do
GidJob.enqueue @person
- assert_equal "Person with ID: 5", $BUFFER.pop
+ assert_equal "Person with ID: 5", Thread.current[:ajbuffer].pop
end
end
diff --git a/activejob/test/cases/logging_test.rb b/activejob/test/cases/logging_test.rb
index 3f21fa644c..f0f315c906 100644
--- a/activejob/test/cases/logging_test.rb
+++ b/activejob/test/cases/logging_test.rb
@@ -23,7 +23,7 @@ class AdapterTest < ActiveSupport::TestCase
def setup
super
- $BUFFER = []
+ Thread.current[:ajbuffer] = []
@old_logger = ActiveJob::Base.logger
@logger = ActiveSupport::TaggedLogging.new(TestLogger.new)
set_logger @logger
diff --git a/activejob/test/cases/queuing_test.rb b/activejob/test/cases/queuing_test.rb
index 3dd9ecd8d2..49760ce9c0 100644
--- a/activejob/test/cases/queuing_test.rb
+++ b/activejob/test/cases/queuing_test.rb
@@ -5,17 +5,17 @@ require 'active_support/core_ext/numeric/time'
class QueuingTest < ActiveSupport::TestCase
setup do
- $BUFFER = []
+ Thread.current[:ajbuffer] = []
end
test 'run queued job' do
HelloJob.enqueue
- assert_equal "David says hello", $BUFFER.pop
+ assert_equal "David says hello", Thread.current[:ajbuffer].pop
end
test 'run queued job with arguments' do
HelloJob.enqueue "Jamie"
- assert_equal "Jamie says hello", $BUFFER.pop
+ assert_equal "Jamie says hello", Thread.current[:ajbuffer].pop
end
test 'run queued job later' do
@@ -26,13 +26,13 @@ class QueuingTest < ActiveSupport::TestCase
skip
end
end
-
+
test 'job returned by enqueue has the arguments available' do
job = HelloJob.enqueue "Jamie"
assert_equal [ "Jamie" ], job.arguments
end
-
+
test 'job returned by enqueue_at has the timestamp available' do
begin
job = HelloJob.enqueue_at Time.utc(2014, 1, 1)
diff --git a/activejob/test/cases/rescue_test.rb b/activejob/test/cases/rescue_test.rb
index 3d4831bc62..4fbd27fe6c 100644
--- a/activejob/test/cases/rescue_test.rb
+++ b/activejob/test/cases/rescue_test.rb
@@ -5,13 +5,13 @@ require 'active_support/core_ext/object/inclusion'
class RescueTest < ActiveSupport::TestCase
setup do
- $BUFFER = []
+ Thread.current[:ajbuffer] = []
end
test 'rescue perform exception with retry' do
job = RescueJob.new
job.execute(SecureRandom.uuid, "david")
- assert_equal [ "rescued from ArgumentError", "performed beautifully" ], $BUFFER
+ assert_equal [ "rescued from ArgumentError", "performed beautifully" ], Thread.current[:ajbuffer]
end
test 'let through unhandled perform exception' do
diff --git a/activejob/test/jobs/gid_job.rb b/activejob/test/jobs/gid_job.rb
index c69e38d3cc..eeb34c8a87 100644
--- a/activejob/test/jobs/gid_job.rb
+++ b/activejob/test/jobs/gid_job.rb
@@ -1,6 +1,6 @@
class GidJob < ActiveJob::Base
def perform(person)
- $BUFFER << "Person with ID: #{person.id}"
+ Thread.current[:ajbuffer] << "Person with ID: #{person.id}"
end
end
- \ No newline at end of file
+
diff --git a/activejob/test/jobs/hello_job.rb b/activejob/test/jobs/hello_job.rb
index 25441dd0c8..cb067bbe69 100644
--- a/activejob/test/jobs/hello_job.rb
+++ b/activejob/test/jobs/hello_job.rb
@@ -1,5 +1,5 @@
class HelloJob < ActiveJob::Base
def perform(greeter = "David")
- $BUFFER << "#{greeter} says hello"
+ Thread.current[:ajbuffer] << "#{greeter} says hello"
end
end
diff --git a/activejob/test/jobs/rescue_job.rb b/activejob/test/jobs/rescue_job.rb
index acf2b81515..e42de4876e 100644
--- a/activejob/test/jobs/rescue_job.rb
+++ b/activejob/test/jobs/rescue_job.rb
@@ -2,7 +2,7 @@ class RescueJob < ActiveJob::Base
class OtherError < StandardError; end
rescue_from(ArgumentError) do
- $BUFFER << "rescued from ArgumentError"
+ Thread.current[:ajbuffer] << "rescued from ArgumentError"
arguments[0] = "DIFFERENT!"
retry_now
end
@@ -14,7 +14,7 @@ class RescueJob < ActiveJob::Base
when "other"
raise OtherError
else
- $BUFFER << "performed beautifully"
+ Thread.current[:ajbuffer] << "performed beautifully"
end
end
end