aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2012-11-26 02:41:45 -0800
committerCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2012-11-26 02:41:45 -0800
commit02c30c64262fd9e1625bc7f3723729c4e62e610b (patch)
tree2f45d92861b7b8c218055dde84b84a851d9fdadc /actionpack
parent1081ae20fb1d23b27e21e3e9f1de62253e34804f (diff)
parent3f2c011d319de8f188b98c286db3786990856de0 (diff)
downloadrails-02c30c64262fd9e1625bc7f3723729c4e62e610b.tar.gz
rails-02c30c64262fd9e1625bc7f3723729c4e62e610b.tar.bz2
rails-02c30c64262fd9e1625bc7f3723729c4e62e610b.zip
Merge pull request #8316 from roberto/assert_template_validate_options
assert_template: validating option keys It only handles the keys locals, partial, layout and count. assert_template(foo: "bar") # raises ArgumentError assert_template(leiaute: "test") # raises ArgumentError
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'