diff options
author | Justin Coyne <justin@curationexperts.com> | 2013-02-27 09:44:25 -0600 |
---|---|---|
committer | Justin Coyne <justin@curationexperts.com> | 2013-03-01 07:22:38 -0600 |
commit | 73deb3af23765882f67869afb4eaa8ad74a351d1 (patch) | |
tree | 846c47334e3ba2e9aabb6bc9c396841b4ed65776 /actionpack/lib/action_controller | |
parent | b49a2a779ba6deba108d1f842ab5b7bc7460aa14 (diff) | |
download | rails-73deb3af23765882f67869afb4eaa8ad74a351d1.tar.gz rails-73deb3af23765882f67869afb4eaa8ad74a351d1.tar.bz2 rails-73deb3af23765882f67869afb4eaa8ad74a351d1.zip |
Allow use of assert_template with the :file option.
This worked in Rails 3.2, but was a regression in 4.0.0.beta1
Diffstat (limited to 'actionpack/lib/action_controller')
-rw-r--r-- | actionpack/lib/action_controller/test_case.rb | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/actionpack/lib/action_controller/test_case.rb b/actionpack/lib/action_controller/test_case.rb index bba1f1e201..e12bf0a1c6 100644 --- a/actionpack/lib/action_controller/test_case.rb +++ b/actionpack/lib/action_controller/test_case.rb @@ -16,6 +16,7 @@ module ActionController @_partials = Hash.new(0) @_templates = Hash.new(0) @_layouts = Hash.new(0) + @_files = Hash.new(0) ActiveSupport::Notifications.subscribe("render_template.action_view") do |name, start, finish, id, payload| path = payload[:layout] @@ -39,6 +40,16 @@ module ActionController @_templates[path] += 1 end + + ActiveSupport::Notifications.subscribe("!render_template.action_view") do |name, start, finish, id, payload| + path = payload[:identifier] + next if payload[:virtual_path] # files don't have virtual path + if path + @_files[path] += 1 + @_files[path.split("/").last] += 1 + end + + end end def teardown_subscriptions @@ -106,7 +117,7 @@ module ActionController end assert matches_template, msg when Hash - options.assert_valid_keys(:layout, :partial, :locals, :count) + options.assert_valid_keys(:layout, :partial, :locals, :count, :file) if options.key?(:layout) expected_layout = options[:layout] @@ -123,6 +134,10 @@ module ActionController end end + if options[:file] + assert_includes @_files.keys, options[:file] + end + if expected_partial = options[:partial] if expected_locals = options[:locals] if defined?(@_rendered_views) |