diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-01-29 20:44:58 -0200 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-01-29 20:44:58 -0200 |
commit | 6bc179075d95030cee4c143b472345fa7f12b1b9 (patch) | |
tree | 0cd9fca8ca77d7326254212238deb394dee8d888 /activerecord/test | |
parent | bd0173574ca908acca3f29b9da7db03bd6a89436 (diff) | |
parent | c9346322b15c15f51234c33a3db1b3895ffe84ab (diff) | |
download | rails-6bc179075d95030cee4c143b472345fa7f12b1b9.tar.gz rails-6bc179075d95030cee4c143b472345fa7f12b1b9.tar.bz2 rails-6bc179075d95030cee4c143b472345fa7f12b1b9.zip |
Merge pull request #13867 from mauricio/bug-13861
Fixing issue with activerecord serialization not being able to dump a record after loading it from YAML - fixes #13861
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/store_test.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/activerecord/test/cases/store_test.rb b/activerecord/test/cases/store_test.rb index 6f632b4d8d..e24df6abe9 100644 --- a/activerecord/test/cases/store_test.rb +++ b/activerecord/test/cases/store_test.rb @@ -166,4 +166,27 @@ class StoreTest < ActiveRecord::TestCase test "YAML coder initializes the store when a Nil value is given" do assert_equal({}, @john.params) end + + test "attributes_for_coder should return stored fields already serialized" do + attributes = { + "id" => @john.id, + "name"=> @john.name, + "settings" => "--- !ruby/hash:ActiveSupport::HashWithIndifferentAccess\ncolor: black\n", + "preferences" => "--- !ruby/hash:ActiveSupport::HashWithIndifferentAccess\nremember_login: true\n", + "json_data" => "{\"height\":\"tall\"}", "json_data_empty"=>"{\"is_a_good_guy\":true}", + "params" => "--- !ruby/hash:ActiveSupport::HashWithIndifferentAccess {}\n", + "account_id"=> @john.account_id } + assert_equal attributes, @john.attributes_for_coder + end + + test "dump, load and dump again a model" do + dumped = YAML.dump( @john ) + loaded = YAML.load( dumped ) + assert_equal @john, loaded + + second_dump = YAML.dump( loaded ) + assert_equal dumped, second_dump + assert_equal @john, YAML.load( second_dump ) + end + end |