diff options
author | Guo Xiang Tan <tgx_world@hotmail.com> | 2014-07-08 14:48:36 +0800 |
---|---|---|
committer | Guo Xiang Tan <tgx_world@hotmail.com> | 2014-07-08 15:25:14 +0800 |
commit | b925074bdd403e678f8dada49bf68a6d9e4e00ee (patch) | |
tree | e936ffeb1a1415656151c8e86b5dc633033604b9 /actionpack/lib | |
parent | e0c6b35dac32b6375c86d93e992a138dd627157e (diff) | |
download | rails-b925074bdd403e678f8dada49bf68a6d9e4e00ee.tar.gz rails-b925074bdd403e678f8dada49bf68a6d9e4e00ee.tar.bz2 rails-b925074bdd403e678f8dada49bf68a6d9e4e00ee.zip |
Reduce number of subscriptions created.
Diffstat (limited to 'actionpack/lib')
-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 |