diff options
author | Abdelkader Boudih <terminale@gmail.com> | 2014-08-29 08:28:07 +0000 |
---|---|---|
committer | Abdelkader Boudih <terminale@gmail.com> | 2014-08-29 08:50:09 +0000 |
commit | d56caea4269abbc6d13f63de40e3b686b13a066f (patch) | |
tree | fbd5c96c4ce8b7e591669d28677cc51559cce38b /activejob/test | |
parent | 82cb3de461d15c1e59b49465ce714594a45b7f5f (diff) | |
download | rails-d56caea4269abbc6d13f63de40e3b686b13a066f.tar.gz rails-d56caea4269abbc6d13f63de40e3b686b13a066f.tar.bz2 rails-d56caea4269abbc6d13f63de40e3b686b13a066f.zip |
[ActiveJob] extract JobBuffer from helper
Diffstat (limited to 'activejob/test')
-rw-r--r-- | activejob/test/helper.rb | 20 | ||||
-rw-r--r-- | activejob/test/jobs/gid_job.rb | 2 | ||||
-rw-r--r-- | activejob/test/jobs/hello_job.rb | 2 | ||||
-rw-r--r-- | activejob/test/jobs/rescue_job.rb | 2 | ||||
-rw-r--r-- | activejob/test/support/job_buffer.rb | 19 |
5 files changed, 25 insertions, 20 deletions
diff --git a/activejob/test/helper.rb b/activejob/test/helper.rb index ca67700273..a56b35da12 100644 --- a/activejob/test/helper.rb +++ b/activejob/test/helper.rb @@ -28,23 +28,3 @@ require "adapters/#{@adapter}" require 'active_support/testing/autorun' ActiveJob::Base.logger.level = Logger::DEBUG - -module JobBuffer - class << self - def clear - @buffer = [] - end - - def add(value) - @buffer << value - end - - def values - @buffer - end - - def last_value - @buffer.last - end - end -end diff --git a/activejob/test/jobs/gid_job.rb b/activejob/test/jobs/gid_job.rb index 35c2366ec4..e485bfa2dd 100644 --- a/activejob/test/jobs/gid_job.rb +++ b/activejob/test/jobs/gid_job.rb @@ -1,3 +1,5 @@ +require_relative '../support/job_buffer' + class GidJob < ActiveJob::Base def perform(person) JobBuffer.add("Person with ID: #{person.id}") diff --git a/activejob/test/jobs/hello_job.rb b/activejob/test/jobs/hello_job.rb index 4c6256af0d..022fa58e4a 100644 --- a/activejob/test/jobs/hello_job.rb +++ b/activejob/test/jobs/hello_job.rb @@ -1,3 +1,5 @@ +require_relative '../support/job_buffer' + class HelloJob < ActiveJob::Base def perform(greeter = "David") JobBuffer.add("#{greeter} says hello") diff --git a/activejob/test/jobs/rescue_job.rb b/activejob/test/jobs/rescue_job.rb index e9cb37d1c4..6b6e74e9d0 100644 --- a/activejob/test/jobs/rescue_job.rb +++ b/activejob/test/jobs/rescue_job.rb @@ -1,3 +1,5 @@ +require_relative '../support/job_buffer' + class RescueJob < ActiveJob::Base class OtherError < StandardError; end diff --git a/activejob/test/support/job_buffer.rb b/activejob/test/support/job_buffer.rb new file mode 100644 index 0000000000..620cb5288d --- /dev/null +++ b/activejob/test/support/job_buffer.rb @@ -0,0 +1,19 @@ +module JobBuffer + class << self + def clear + values.clear + end + + def add(value) + values << value + end + + def values + @values ||= [] + end + + def last_value + values.last + end + end +end |