aboutsummaryrefslogtreecommitdiffstats
path: root/activejob/lib/active_job/queue_adapters
diff options
context:
space:
mode:
authorEdouard CHIN <edouard.chin@shopify.com>2018-11-21 22:43:14 +0100
committerEdouard CHIN <edouard.chin@shopify.com>2018-11-21 23:14:43 +0100
commitcdb16ac576198607916cde6d55fe14cb775a98c9 (patch)
tree2904093cd2a45b8a3b42cbfde48f65ede86c41d7 /activejob/lib/active_job/queue_adapters
parentca0339215f07dfbb927d727b3f66701f176d0a67 (diff)
downloadrails-cdb16ac576198607916cde6d55fe14cb775a98c9.tar.gz
rails-cdb16ac576198607916cde6d55fe14cb775a98c9.tar.bz2
rails-cdb16ac576198607916cde6d55fe14cb775a98c9.zip
Allow all ActiveJob assertion helper to accept Proc in their `only` kw:
- That feature is useful to enqueue or assert that jobs got enqueued or performed based on dynamic conditions. We will be able to leverage that feature to fix all ActionMailer assertion helper issue when a Mailer define a custom delivery job (see next commit).
Diffstat (limited to 'activejob/lib/active_job/queue_adapters')
-rw-r--r--activejob/lib/active_job/queue_adapters/test_adapter.rb10
1 files changed, 8 insertions, 2 deletions
diff --git a/activejob/lib/active_job/queue_adapters/test_adapter.rb b/activejob/lib/active_job/queue_adapters/test_adapter.rb
index f73ad444ba..c134257ebc 100644
--- a/activejob/lib/active_job/queue_adapters/test_adapter.rb
+++ b/activejob/lib/active_job/queue_adapters/test_adapter.rb
@@ -65,11 +65,17 @@ module ActiveJob
def filtered_job_class?(job)
if filter
- !Array(filter).include?(job.class)
+ !filter_as_proc(filter).call(job)
elsif reject
- Array(reject).include?(job.class)
+ filter_as_proc(reject).call(job)
end
end
+
+ def filter_as_proc(filter)
+ return filter if filter.is_a?(Proc)
+
+ ->(job) { Array(filter).include?(job.class) }
+ end
end
end
end