diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2010-11-23 11:10:56 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-11-23 14:29:04 -0800 |
commit | 28f4df0908180783f8cf863a8bbb30c1c139bd8d (patch) | |
tree | 8c769c9d2f31748d082e5512582aad3cb9c1d3e0 /activerecord/test | |
parent | 4c1f76eaab670ffa95d185374ea91f0d2e2818c7 (diff) | |
download | rails-28f4df0908180783f8cf863a8bbb30c1c139bd8d.tar.gz rails-28f4df0908180783f8cf863a8bbb30c1c139bd8d.tar.bz2 rails-28f4df0908180783f8cf863a8bbb30c1c139bd8d.zip |
testing duped attributes are independent
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/duplication_test.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/activerecord/test/cases/duplication_test.rb b/activerecord/test/cases/duplication_test.rb index c6f7e3ef16..1ca6e72db0 100644 --- a/activerecord/test/cases/duplication_test.rb +++ b/activerecord/test/cases/duplication_test.rb @@ -41,6 +41,13 @@ module ActiveRecord assert cloned.frozen?, 'topic should be frozen' end + def test_clone_is_shallow + topic = Topic.first + cloned = topic.clone + topic.author_name = 'Aaron' + assert_equal 'Aaron', cloned.author_name + end + def test_dup_with_modified_attributes topic = Topic.first topic.author_name = 'Aaron' @@ -64,5 +71,16 @@ module ActiveRecord assert_not_equal topic.changes, duped.changes end + + def test_dup_attributes_are_independent + topic = Topic.first + duped = topic.dup + + duped.author_name = 'meow' + topic.author_name = 'Aaron' + + assert_equal 'Aaron', topic.author_name + assert_equal 'meow', duped.author_name + end end end |