aboutsummaryrefslogtreecommitdiffstats
path: root/activejob
diff options
context:
space:
mode:
authorYves Senn <yves.senn@gmail.com>2014-10-23 08:34:15 +0200
committerYves Senn <yves.senn@gmail.com>2014-10-23 08:34:15 +0200
commit2e38f8324142896376bcdd2fa5aa430a35505f0a (patch)
treeb8aebdda60ff2222214dcbb383f693c3d9d610c5 /activejob
parent04b40b3debebc24e11a1d9c81ea313125500185b (diff)
parent588b39e1cdf09dddf3a02ff4b062d5a09a0911e9 (diff)
downloadrails-2e38f8324142896376bcdd2fa5aa430a35505f0a.tar.gz
rails-2e38f8324142896376bcdd2fa5aa430a35505f0a.tar.bz2
rails-2e38f8324142896376bcdd2fa5aa430a35505f0a.zip
Merge pull request #17343 from vipulnsward/inline-aj-callbacks
Inline AJ around_perform and around_enqueue in CallbackJob used for tests
Diffstat (limited to 'activejob')
-rw-r--r--activejob/test/jobs/callback_job.rb29
1 files changed, 13 insertions, 16 deletions
diff --git a/activejob/test/jobs/callback_job.rb b/activejob/test/jobs/callback_job.rb
index 056dd073e8..891ed9464e 100644
--- a/activejob/test/jobs/callback_job.rb
+++ b/activejob/test/jobs/callback_job.rb
@@ -1,12 +1,21 @@
class CallbackJob < ActiveJob::Base
before_perform ->(job) { job.history << "CallbackJob ran before_perform" }
- after_perform ->(job) { job.history << "CallbackJob ran after_perform" }
+ after_perform ->(job) { job.history << "CallbackJob ran after_perform" }
before_enqueue ->(job) { job.history << "CallbackJob ran before_enqueue" }
- after_enqueue ->(job) { job.history << "CallbackJob ran after_enqueue" }
+ after_enqueue ->(job) { job.history << "CallbackJob ran after_enqueue" }
- around_perform :around_perform
- around_enqueue :around_enqueue
+ around_perform do |job, block|
+ job.history << "CallbackJob ran around_perform_start"
+ block.call
+ job.history << "CallbackJob ran around_perform_stop"
+ end
+
+ around_enqueue do |job, block|
+ job.history << "CallbackJob ran around_enqueue_start"
+ block.call
+ job.history << "CallbackJob ran around_enqueue_stop"
+ end
def perform(person = "david")
@@ -17,16 +26,4 @@ class CallbackJob < ActiveJob::Base
@history ||= []
end
- # FIXME: Not sure why these can't be declared inline like before/after
- def around_perform
- history << "CallbackJob ran around_perform_start"
- yield
- history << "CallbackJob ran around_perform_stop"
- end
-
- def around_enqueue
- history << "CallbackJob ran around_enqueue_start"
- yield
- history << "CallbackJob ran around_enqueue_stop"
- end
end