1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Fix subscriptions not being unsubscribed.

This commit is contained in:
Guo Xiang Tan 2014-04-07 21:42:27 -07:00
parent 80d0dd53ca
commit 26ff72feaf
2 changed files with 9 additions and 6 deletions

View file

@ -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)

View file

@ -235,7 +235,8 @@ module ActionView
:@options,
:@test_passed,
:@view,
:@view_context_class
:@view_context_class,
:@_subscribers
]
def _user_defined_ivars