1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

assert_template: validating option keys

This commit is contained in:
Roberto Soares 2012-11-25 23:39:08 -03:00
parent 4d0dc53249
commit 3f2c011d31
3 changed files with 11 additions and 1 deletions

View file

@ -1,6 +1,8 @@
## Rails 4.0.0 (unreleased) ##
* `assert_template` is no more passing with empty string.
* `assert_template`:
- is no more passing with empty string.
- is now validating option keys. It accepts: `:layout`, `:partial`, `:locals` and `:count`.
*Roberto Soares*

View file

@ -106,6 +106,8 @@ module ActionController
end
assert matches_template, msg
when Hash
options.assert_valid_keys(:layout, :partial, :locals, :count)
if options.key?(:layout)
expected_layout = options[:layout]
msg = message || sprintf("expecting layout <%s> but action rendered <%s>",

View file

@ -430,6 +430,12 @@ end
class AssertTemplateTest < ActionController::TestCase
tests ActionPackAssertionsController
def test_with_invalid_hash_keys_raises_argument_error
assert_raise(ArgumentError) do
assert_template foo: "bar"
end
end
def test_with_partial
get :partial
assert_template :partial => '_partial'