提交 88b16843 编写于 作者: R Rafael França 提交者: GitHub

Merge pull request #28056 from sngeth/wrap_store_accessors_in_params

Wrap stored accessors in parameters
......@@ -105,7 +105,11 @@ def include
unless super || exclude
if m.respond_to?(:attribute_names) && m.attribute_names.any?
self.include = m.attribute_names
if m.respond_to?(:stored_attributes) && !m.stored_attributes.empty?
self.include = m.attribute_names + m.stored_attributes.values.flatten.map(&:to_s)
else
self.include = m.attribute_names
end
end
end
end
......
......@@ -35,6 +35,10 @@ def self.attribute_names
end
class Person
def self.stores_attributes
{ settings: [:color, :size] }
end
def self.attribute_names
[]
end
......@@ -62,6 +66,15 @@ def test_derived_name_from_controller
end
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" })
end
end
def test_specify_wrapper_name
with_default_wrapper_options do
UsersController.wrap_parameters :person
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册