aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2012-11-25 16:45:55 -0800
committerCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2012-11-25 16:45:55 -0800
commit4d0dc53249aefc75a7d258e256b268198a7dd7a1 (patch)
treec6f5c11186c177309e178409b7e1242adb4634e1 /actionpack
parent0a7ba19dcc2271ad6183041ca79e8766a0d2bc40 (diff)
parent2d6c4ec731861225779f3106f038effb17a27b21 (diff)
downloadrails-4d0dc53249aefc75a7d258e256b268198a7dd7a1.tar.gz
rails-4d0dc53249aefc75a7d258e256b268198a7dd7a1.tar.bz2
rails-4d0dc53249aefc75a7d258e256b268198a7dd7a1.zip
Merge pull request #8302 from roberto/assert_template_empty_string
assert_template("") will now fail no matter whether a template has been rendered or not.
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/CHANGELOG.md4
-rw-r--r--actionpack/lib/action_controller/test_case.rb2
-rw-r--r--actionpack/test/controller/action_pack_assertions_test.rb14
3 files changed, 19 insertions, 1 deletions
diff --git a/actionpack/CHANGELOG.md b/actionpack/CHANGELOG.md
index 85a83ed7d9..60af09083d 100644
--- a/actionpack/CHANGELOG.md
+++ b/actionpack/CHANGELOG.md
@@ -1,5 +1,9 @@
## Rails 4.0.0 (unreleased) ##
+* `assert_template` is no more passing with empty string.
+
+ *Roberto Soares*
+
* Allow setting a symbol as path in scope on routes. This is now allowed:
scope :api do
diff --git a/actionpack/lib/action_controller/test_case.rb b/actionpack/lib/action_controller/test_case.rb
index be8055955d..586dd3cdf9 100644
--- a/actionpack/lib/action_controller/test_case.rb
+++ b/actionpack/lib/action_controller/test_case.rb
@@ -94,7 +94,7 @@ module ActionController
matches_template =
case options
when String
- rendered.any? do |t, num|
+ !options.empty? && 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
diff --git a/actionpack/test/controller/action_pack_assertions_test.rb b/actionpack/test/controller/action_pack_assertions_test.rb
index ca542eb7e2..5f559e5b00 100644
--- a/actionpack/test/controller/action_pack_assertions_test.rb
+++ b/actionpack/test/controller/action_pack_assertions_test.rb
@@ -447,6 +447,20 @@ class AssertTemplateTest < ActionController::TestCase
end
end
+ def test_with_empty_string_fails_when_template_rendered
+ get :hello_world
+ assert_raise(ActiveSupport::TestCase::Assertion) do
+ assert_template ""
+ end
+ end
+
+ def test_with_empty_string_fails_when_no_template_rendered
+ get :nothing
+ assert_raise(ActiveSupport::TestCase::Assertion) do
+ assert_template ""
+ end
+ end
+
def test_passes_with_correct_string
get :hello_world
assert_template 'hello_world'