aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorRoberto Soares <roberto.tech@gmail.com>2012-11-25 23:39:08 -0300
committerRoberto Soares <roberto.tech@gmail.com>2012-11-25 23:39:08 -0300
commit3f2c011d319de8f188b98c286db3786990856de0 (patch)
tree6759f589a606d850e60a6b894f0e2ed1d3aead64 /actionpack
parent4d0dc53249aefc75a7d258e256b268198a7dd7a1 (diff)
downloadrails-3f2c011d319de8f188b98c286db3786990856de0.tar.gz
rails-3f2c011d319de8f188b98c286db3786990856de0.tar.bz2
rails-3f2c011d319de8f188b98c286db3786990856de0.zip
assert_template: validating option keys
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.rb6
3 files changed, 11 insertions, 1 deletions
diff --git a/actionpack/CHANGELOG.md b/actionpack/CHANGELOG.md
index 60af09083d..0c47934c1e 100644
--- a/actionpack/CHANGELOG.md
+++ b/actionpack/CHANGELOG.md
@@ -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*
diff --git a/actionpack/lib/action_controller/test_case.rb b/actionpack/lib/action_controller/test_case.rb
index 586dd3cdf9..7b48870090 100644
--- a/actionpack/lib/action_controller/test_case.rb
+++ b/actionpack/lib/action_controller/test_case.rb
@@ -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>",
diff --git a/actionpack/test/controller/action_pack_assertions_test.rb b/actionpack/test/controller/action_pack_assertions_test.rb
index 5f559e5b00..b94f45bfe7 100644
--- a/actionpack/test/controller/action_pack_assertions_test.rb
+++ b/actionpack/test/controller/action_pack_assertions_test.rb
@@ -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'