diff options
author | Jeremy Kemper <jeremykemper@gmail.com> | 2015-03-06 10:41:46 -0700 |
---|---|---|
committer | Jeremy Kemper <jeremykemper@gmail.com> | 2015-03-06 10:42:49 -0700 |
commit | a3e490419a2c6d36360e9186973ebbee6335623d (patch) | |
tree | 22e14c8e0c1fc4f345c3c582d4b991fa2c9e6f80 /activejob/lib | |
parent | e81693a0ebce0d1f6f259230847bca0109192c71 (diff) | |
download | rails-a3e490419a2c6d36360e9186973ebbee6335623d.tar.gz rails-a3e490419a2c6d36360e9186973ebbee6335623d.tar.bz2 rails-a3e490419a2c6d36360e9186973ebbee6335623d.zip |
Fix leaky `only: …` option for Active Job assertions
The filter was set on the pseudo-global TestAdapter but not restored to
its original value.
See e818f65770fe115ab1cc7fbacc0e7e94d92af6a4
Diffstat (limited to 'activejob/lib')
-rw-r--r-- | activejob/lib/active_job/test_helper.rb | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/activejob/lib/active_job/test_helper.rb b/activejob/lib/active_job/test_helper.rb index 66508114d1..bb8b267c31 100644 --- a/activejob/lib/active_job/test_helper.rb +++ b/activejob/lib/active_job/test_helper.rb @@ -13,6 +13,7 @@ module ActiveJob clear_performed_jobs queue_adapter.perform_enqueued_jobs = false queue_adapter.perform_enqueued_at_jobs = false + queue_adapter.filter = nil super end @@ -253,15 +254,20 @@ module ActiveJob end def perform_enqueued_jobs(only: nil) - @old_perform_enqueued_jobs = queue_adapter.perform_enqueued_jobs - @old_perform_enqueued_at_jobs = queue_adapter.perform_enqueued_at_jobs - queue_adapter.perform_enqueued_jobs = true - queue_adapter.perform_enqueued_at_jobs = true - queue_adapter.filter = only - yield - ensure - queue_adapter.perform_enqueued_jobs = @old_perform_enqueued_jobs - queue_adapter.perform_enqueued_at_jobs = @old_perform_enqueued_at_jobs + old_perform_enqueued_jobs = queue_adapter.perform_enqueued_jobs + old_perform_enqueued_at_jobs = queue_adapter.perform_enqueued_at_jobs + old_filter = queue_adapter.filter + + begin + queue_adapter.perform_enqueued_jobs = true + queue_adapter.perform_enqueued_at_jobs = true + queue_adapter.filter = only + yield + ensure + queue_adapter.perform_enqueued_jobs = old_perform_enqueued_jobs + queue_adapter.perform_enqueued_at_jobs = old_perform_enqueued_at_jobs + queue_adapter.filter = old_filter + end end def queue_adapter |