Skip to content

Commit

Permalink
Update assertion on nil stripping
Browse files Browse the repository at this point in the history
The behavior of `deep_munge` was changed in rails/rails#16924 for
security reason, so we should expect a different outcome when running
against Rails 5.0+.
  • Loading branch information
sikachu committed Apr 17, 2015
1 parent 4eb2328 commit a4a6516
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions test/xml_params_parsing_test.rb
Expand Up @@ -42,9 +42,18 @@ def assert_parses(expected, xml)
end

test "nils are stripped from collections" do
assert_parses(
{"hash" => { "person" => nil} },
"<hash><person type=\"array\"><person nil=\"true\"/></person></hash>")
if ActiveSupport::VERSION::MAJOR >= 5
# Rails 5 changes the behavior of #deep_munge for security reason.
# https://github.com/rails/rails/pull/16924
assert_parses(
{"hash" => { "person" => []} },
"<hash><person type=\"array\"><person nil=\"true\"/></person></hash>")
else
assert_parses(
{"hash" => { "person" => nil} },
"<hash><person type=\"array\"><person nil=\"true\"/></person></hash>")
end

assert_parses(
{"hash" => { "person" => ['foo']} },
"<hash><person type=\"array\"><person>foo</person><person nil=\"true\"/></person>\n</hash>")
Expand Down

0 comments on commit a4a6516

Please sign in to comment.