diff options
author | Yves Senn <yves.senn@gmail.com> | 2014-04-15 08:48:49 +0200 |
---|---|---|
committer | Yves Senn <yves.senn@gmail.com> | 2014-04-15 08:48:49 +0200 |
commit | ab529c89c867e9775b2edcdbfb548f6ec3e15700 (patch) | |
tree | 0aedd5fef97fcea61796dcd24c6c4c7889525c5c /actionpack | |
parent | 43f525031ad3f83a04f84e79bbe1de340bf937aa (diff) | |
parent | 26ff72feaf7c4882892897c80cb5b3d25f5b0a2c (diff) | |
download | rails-ab529c89c867e9775b2edcdbfb548f6ec3e15700.tar.gz rails-ab529c89c867e9775b2edcdbfb548f6ec3e15700.tar.bz2 rails-ab529c89c867e9775b2edcdbfb548f6ec3e15700.zip |
Merge pull request #14642 from tgxworld/fix_notifications_not_unsubscribing
Fix subscriptions not being unsubscribed.
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/lib/action_controller/test_case.rb | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/actionpack/lib/action_controller/test_case.rb b/actionpack/lib/action_controller/test_case.rb index df57efaa97..caaebc537a 100644 --- a/actionpack/lib/action_controller/test_case.rb +++ b/actionpack/lib/action_controller/test_case.rb @@ -17,8 +17,9 @@ module ActionController @_templates = Hash.new(0) @_layouts = Hash.new(0) @_files = Hash.new(0) + @_subscribers = [] - ActiveSupport::Notifications.subscribe("render_template.action_view") do |_name, _start, _finish, _id, payload| + @_subscribers << ActiveSupport::Notifications.subscribe("render_template.action_view") do |_name, _start, _finish, _id, payload| path = payload[:layout] if path @_layouts[path] += 1 @@ -28,7 +29,7 @@ module ActionController end end - ActiveSupport::Notifications.subscribe("!render_template.action_view") do |_name, _start, _finish, _id, payload| + @_subscribers << ActiveSupport::Notifications.subscribe("!render_template.action_view") do |_name, _start, _finish, _id, payload| path = payload[:virtual_path] next unless path partial = path =~ /^.*\/_[^\/]*$/ @@ -41,7 +42,7 @@ module ActionController @_templates[path] += 1 end - ActiveSupport::Notifications.subscribe("!render_template.action_view") do |_name, _start, _finish, _id, payload| + @_subscribers << ActiveSupport::Notifications.subscribe("!render_template.action_view") do |_name, _start, _finish, _id, payload| next if payload[:virtual_path] # files don't have virtual path path = payload[:identifier] @@ -53,8 +54,9 @@ module ActionController end def teardown_subscriptions - ActiveSupport::Notifications.unsubscribe("render_template.action_view") - ActiveSupport::Notifications.unsubscribe("!render_template.action_view") + @_subscribers.each do |subscriber| + ActiveSupport::Notifications.unsubscribe(subscriber) + end end def process(*args) |