Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
- Inline AJ around_perform and around_enqueue in CallbackJob used for…
… tests.
  • Loading branch information
vipulnsward committed Oct 21, 2014
1 parent f1e1894 commit 588b39e
Showing 1 changed file with 13 additions and 16 deletions.
29 changes: 13 additions & 16 deletions 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")
Expand All @@ -17,16 +26,4 @@ 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

0 comments on commit 588b39e

Please sign in to comment.