Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #16740 from seuros/activejob

[ActiveJob] extract JobBuffer from helper
  • Loading branch information...
commit 42d5e785fe47d1217566c7f2dba8fc11d993b51e 2 parents 82cb3de + d56caea
@senny senny authored
View
20 activejob/test/helper.rb
@@ -28,23 +28,3 @@ def ruby_193?
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
View
2  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}")
View
2  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")
View
2  activejob/test/jobs/rescue_job.rb
@@ -1,3 +1,5 @@
+require_relative '../support/job_buffer'
+
class RescueJob < ActiveJob::Base
class OtherError < StandardError; end
View
19 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
Please sign in to comment.
Something went wrong with that request. Please try again.