aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/controller
diff options
context:
space:
mode:
authoryuuji.yaginuma <yuuji.yaginuma@gmail.com>2017-03-22 08:17:26 +0900
committeryuuji.yaginuma <yuuji.yaginuma@gmail.com>2017-03-22 08:20:18 +0900
commitedcbb2e5b7505e072ae981a4eb5b23dc5d537e42 (patch)
tree3bda14b0de8c8c72198de6906812cdaedd9c869b /actionpack/test/controller
parent88b16843f67bcd96395444ba8f139895351da0bc (diff)
downloadrails-edcbb2e5b7505e072ae981a4eb5b23dc5d537e42.tar.gz
rails-edcbb2e5b7505e072ae981a4eb5b23dc5d537e42.tar.bz2
rails-edcbb2e5b7505e072ae981a4eb5b23dc5d537e42.zip
Fix store accessors in parameters test
* The method name must be `stored_attributes`, not `stores_attributes`. * `attribute_names` must return a non-empty value. Because `stored_attributes` is not checked if `attribute_names` is empty. Follow up to #28056
Diffstat (limited to 'actionpack/test/controller')
-rw-r--r--actionpack/test/controller/params_wrapper_test.rb18
1 files changed, 10 insertions, 8 deletions
diff --git a/actionpack/test/controller/params_wrapper_test.rb b/actionpack/test/controller/params_wrapper_test.rb
index 1eb92abae4..2a41d57b26 100644
--- a/actionpack/test/controller/params_wrapper_test.rb
+++ b/actionpack/test/controller/params_wrapper_test.rb
@@ -32,13 +32,13 @@ class ParamsWrapperTest < ActionController::TestCase
def self.attribute_names
[]
end
- end
- class Person
- def self.stores_attributes
+ def self.stored_attributes
{ settings: [:color, :size] }
end
+ end
+ class Person
def self.attribute_names
[]
end
@@ -67,11 +67,13 @@ class ParamsWrapperTest < ActionController::TestCase
end
def test_store_accessors_wrapped
- with_default_wrapper_options do
- @request.env["CONTENT_TYPE"] = "application/json"
- post :parse, params: { "username" => "sikachu", "color" => "blue", "size" => "large" }
- assert_parameters("username" => "sikachu", "color" => "blue", "size" => "large",
- "user" => { "username" => "sikachu", "color" => "blue", "size" => "large" })
+ assert_called(User, :attribute_names, times: 2, returns: ["username"]) do
+ with_default_wrapper_options do
+ @request.env["CONTENT_TYPE"] = "application/json"
+ post :parse, params: { "username" => "sikachu", "color" => "blue", "size" => "large" }
+ assert_parameters("username" => "sikachu", "color" => "blue", "size" => "large",
+ "user" => { "username" => "sikachu", "color" => "blue", "size" => "large" })
+ end
end
end