提交 4d0dc532 编写于 作者: C Carlos Antonio da Silva

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.
## 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
......
......@@ -94,7 +94,7 @@ def assert_template(options = {}, message = nil)
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
......
......@@ -447,6 +447,20 @@ def test_with_nil_fails_when_template_rendered
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'
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册