diff options
author | Kasper Timm Hansen <kaspth@gmail.com> | 2016-08-02 12:50:26 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-08-02 12:50:26 +0200 |
commit | 6b441559b1e4bfa080e99a9f55fb5e8f3ced4864 (patch) | |
tree | 3bc464d5c6c38e7480e9770273f4ce21c03561d3 /actionpack/test | |
parent | c205e3fca333e7c24dd1e36d439f83cdaf074e44 (diff) | |
parent | 31448f2b7fa6f3920485229e5710d9fcf87f190d (diff) | |
download | rails-6b441559b1e4bfa080e99a9f55fb5e8f3ced4864.tar.gz rails-6b441559b1e4bfa080e99a9f55fb5e8f3ced4864.tar.bz2 rails-6b441559b1e4bfa080e99a9f55fb5e8f3ced4864.zip |
Merge pull request #26017 from kaspth/parameters-yaml-format-backwardscompatibility
Make Parameters support legacy YAML encodings.
Diffstat (limited to 'actionpack/test')
-rw-r--r-- | actionpack/test/controller/parameters/serialization_test.rb | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/actionpack/test/controller/parameters/serialization_test.rb b/actionpack/test/controller/parameters/serialization_test.rb new file mode 100644 index 0000000000..5d389f5a4c --- /dev/null +++ b/actionpack/test/controller/parameters/serialization_test.rb @@ -0,0 +1,32 @@ +require 'abstract_unit' +require 'action_controller/metal/strong_parameters' +require 'active_support/core_ext/string/strip' + +class ParametersSerializationTest < ActiveSupport::TestCase + test 'yaml serialization' do + assert_equal <<-end_of_yaml.strip_heredoc, YAML.dump(ActionController::Parameters.new(key: :value)) + --- !ruby/object:ActionController::Parameters + parameters: !ruby/hash:ActiveSupport::HashWithIndifferentAccess + key: :value + permitted: false + end_of_yaml + end + + test 'yaml deserialization' do + params = ActionController::Parameters.new(key: :value) + roundtripped = YAML.load(YAML.dump(params)) + + assert_equal params, roundtripped + assert_not roundtripped.permitted? + end + + test 'yaml backwardscompatible with hash inheriting parameters' do + assert_equal ActionController::Parameters.new(key: :value), YAML.load(<<-end_of_yaml.strip_heredoc) + --- !ruby/hash-with-ivars:ActionController::Parameters + elements: + key: :value + ivars: + :@permitted: false + end_of_yaml + end +end |