aboutsummaryrefslogtreecommitdiffstats
path: root/activejob/test/jobs/callback_job.rb
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2014-08-17 16:54:26 -0700
committerDavid Heinemeier Hansson <david@loudthinking.com>2014-08-17 16:54:26 -0700
commit5d2de5c3b8d71ae7ffd1b4193edc1b169e00cd0e (patch)
tree959cf1f0132d89921fa1a276a2a8dc689e3c3aa0 /activejob/test/jobs/callback_job.rb
parentc20c86ee9e944e38ce0eb581e4af3ad4af839875 (diff)
parent49c9f850fa3e2484e3aaf20b2479f61b1cc9375e (diff)
downloadrails-5d2de5c3b8d71ae7ffd1b4193edc1b169e00cd0e.tar.gz
rails-5d2de5c3b8d71ae7ffd1b4193edc1b169e00cd0e.tar.bz2
rails-5d2de5c3b8d71ae7ffd1b4193edc1b169e00cd0e.zip
Merge branch 'master' of github.com:rails/rails
Diffstat (limited to 'activejob/test/jobs/callback_job.rb')
-rw-r--r--activejob/test/jobs/callback_job.rb32
1 files changed, 32 insertions, 0 deletions
diff --git a/activejob/test/jobs/callback_job.rb b/activejob/test/jobs/callback_job.rb
new file mode 100644
index 0000000000..056dd073e8
--- /dev/null
+++ b/activejob/test/jobs/callback_job.rb
@@ -0,0 +1,32 @@
+class CallbackJob < ActiveJob::Base
+ before_perform ->(job) { job.history << "CallbackJob ran before_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" }
+
+ around_perform :around_perform
+ around_enqueue :around_enqueue
+
+
+ def perform(person = "david")
+ # NOTHING!
+ end
+
+ def history
+ @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