diff options
author | Santiago Pastorino <santiago@wyeworks.com> | 2014-07-09 19:05:13 -0300 |
---|---|---|
committer | Santiago Pastorino <santiago@wyeworks.com> | 2014-07-09 19:05:13 -0300 |
commit | cb377455fe9b97e4760d3b7b4af1b1a004a3f14b (patch) | |
tree | e79ffe817bccbb4def5ef8b41b9b5556fa464a56 /actionpack | |
parent | 05fde24e1ef8c3b225eea8c51cbc05418620ae4a (diff) | |
parent | b925074bdd403e678f8dada49bf68a6d9e4e00ee (diff) | |
download | rails-cb377455fe9b97e4760d3b7b4af1b1a004a3f14b.tar.gz rails-cb377455fe9b97e4760d3b7b4af1b1a004a3f14b.tar.bz2 rails-cb377455fe9b97e4760d3b7b4af1b1a004a3f14b.zip |
Merge pull request #16091 from tgxworld/reduce_creation_of_subscribers
Reduce number of subscriptions created.
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/lib/action_controller/test_case.rb | 30 |
1 files changed, 13 insertions, 17 deletions
diff --git a/actionpack/lib/action_controller/test_case.rb b/actionpack/lib/action_controller/test_case.rb index 8fd11d7cf2..a18c35e3e9 100644 --- a/actionpack/lib/action_controller/test_case.rb +++ b/actionpack/lib/action_controller/test_case.rb @@ -30,25 +30,21 @@ module ActionController end @_subscribers << ActiveSupport::Notifications.subscribe("!render_template.action_view") do |_name, _start, _finish, _id, payload| - path = payload[:virtual_path] - next unless path - partial = path =~ /^.*\/_[^\/]*$/ + if virtual_path = payload[:virtual_path] + partial = virtual_path =~ /^.*\/_[^\/]*$/ - if partial - @_partials[path] += 1 - @_partials[path.split("/").last] += 1 - end - - @_templates[path] += 1 - end - - @_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 + if partial + @_partials[virtual_path] += 1 + @_partials[virtual_path.split("/").last] += 1 + end - path = payload[:identifier] - if path - @_files[path] += 1 - @_files[path.split("/").last] += 1 + @_templates[virtual_path] += 1 + else + path = payload[:identifier] + if path + @_files[path] += 1 + @_files[path.split("/").last] += 1 + end end end end |