diff options
author | Sean Griffin <sean@thoughtbot.com> | 2014-05-31 06:01:59 -0700 |
---|---|---|
committer | Sean Griffin <sean@thoughtbot.com> | 2014-06-01 17:52:46 -0600 |
commit | e08494a912c89b1eb444c5c358e9aa880b2e4c66 (patch) | |
tree | e61c768fa2fc42e612c17b2fb19e758d062a454d /activerecord/test | |
parent | 87cc918daab39174c82b0aeb617fb8e4b4f107fb (diff) | |
download | rails-e08494a912c89b1eb444c5c358e9aa880b2e4c66.tar.gz rails-e08494a912c89b1eb444c5c358e9aa880b2e4c66.tar.bz2 rails-e08494a912c89b1eb444c5c358e9aa880b2e4c66.zip |
New records should remain new after yaml serialization
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/yaml_serialization_test.rb | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/activerecord/test/cases/yaml_serialization_test.rb b/activerecord/test/cases/yaml_serialization_test.rb index f7af9a35cd..d4f8ef5b4d 100644 --- a/activerecord/test/cases/yaml_serialization_test.rb +++ b/activerecord/test/cases/yaml_serialization_test.rb @@ -52,4 +52,21 @@ class YamlSerializationTest < ActiveRecord::TestCase assert_equal 123, topic.parent_id assert_equal 123, YAML.load(YAML.dump(topic)).parent_id end + + def test_new_records_remain_new_after_round_trip + topic = Topic.new + + assert topic.new_record?, "Sanity check that new records are new" + assert YAML.load(YAML.dump(topic)).new_record?, "Record should be new after deserialization" + + topic.save! + + assert_not topic.new_record?, "Saved records are not new" + assert_not YAML.load(YAML.dump(topic)).new_record?, "Saved record should not be new after deserialization" + + topic = Topic.select('title').last + + assert_not topic.new_record?, "Loaded records without ID are not new" + assert_not YAML.load(YAML.dump(topic)).new_record?, "Record should not be new after deserialization" + end end |