diff options
author | Hugo Roque <hugolnx@gmail.com> | 2012-04-07 00:27:47 -0300 |
---|---|---|
committer | Hugo Roque <hugolnx@gmail.com> | 2012-09-29 23:31:49 -0300 |
commit | 19dff78d0202303f7559921f24b9801722695f33 (patch) | |
tree | c0d1fba0790252e074c4a1c11f9dacd5eacc8ac5 /actionpack/lib | |
parent | f655108c260ccd334e494b7d6da8822b31cc2156 (diff) | |
download | rails-19dff78d0202303f7559921f24b9801722695f33.tar.gz rails-19dff78d0202303f7559921f24b9801722695f33.tar.bz2 rails-19dff78d0202303f7559921f24b9801722695f33.zip |
`assert_template` no more passing with what ever string that matches.
Given Im rendering an template `/layout/hello.html.erb`, assert_template was
passing with any string that matches. This behavior allowed false passing like:
assert_template "layout"
assert_template "out/hello"
Now the passing possibilities are:
assert_template "layout/hello"
assert_template "hello"
fixing assert_template bug when template matches expected, but not ends with
Cherry Pick Merge: Fixes issue #3849 assert_template false positive
taking redundant test off
prevening incorrect assert_template when rendering with repeated names in path
updating CHANGELOG with bugfix: assert_template false passing
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_controller/test_case.rb | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/actionpack/lib/action_controller/test_case.rb b/actionpack/lib/action_controller/test_case.rb index 0caeef3192..34974f5149 100644 --- a/actionpack/lib/action_controller/test_case.rb +++ b/actionpack/lib/action_controller/test_case.rb @@ -86,16 +86,23 @@ module ActionController response.body case options - when NilClass, String, Symbol, Regexp + when NilClass, Regexp, String, Symbol options = options.to_s if Symbol === options rendered = @templates msg = message || sprintf("expecting <%s> but rendering with <%s>", options.inspect, rendered.keys) - matches_template = - if options + matches_template = + case options + when String + rendered.any? do |t, num| + options_splited = options.split(File::SEPARATOR) + t_splited = t.split(File::SEPARATOR) + t_splited.last(options_splited.size) == options_splited + end + when Regexp rendered.any? { |t,num| t.match(options) } - else - @templates.blank? + when NilClass + rendered.blank? end assert matches_template, msg when Hash |