diff options
author | Roberto Soares <roberto.tech@gmail.com> | 2012-11-23 16:13:08 -0300 |
---|---|---|
committer | Roberto Soares <roberto.tech@gmail.com> | 2012-11-23 16:15:17 -0300 |
commit | 20723ca49873076d8fc8c2bf0729568373e31738 (patch) | |
tree | e08be318835b970b676c77f7ed7af42cc2317f02 /actionpack/lib | |
parent | 36ee5802a5e52e0720eaa80fd0473fd131ffe890 (diff) | |
download | rails-20723ca49873076d8fc8c2bf0729568373e31738.tar.gz rails-20723ca49873076d8fc8c2bf0729568373e31738.tar.bz2 rails-20723ca49873076d8fc8c2bf0729568373e31738.zip |
`assert_template` fails with empty string when a template has been rendered
For instance, it prevents false positive in this case:
file = nil
get :index
assert_template("#{file}")
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_controller/test_case.rb | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/actionpack/lib/action_controller/test_case.rb b/actionpack/lib/action_controller/test_case.rb index be8055955d..fd3a261a72 100644 --- a/actionpack/lib/action_controller/test_case.rb +++ b/actionpack/lib/action_controller/test_case.rb @@ -94,10 +94,14 @@ module ActionController 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 + if options.empty? + rendered.blank? + else + 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 end when Regexp rendered.any? { |t,num| t.match(options) } |