diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2010-11-23 10:13:43 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-11-23 14:29:03 -0800 |
commit | ca7b0a0d1a424aec0973fe22c299b8f04e309784 (patch) | |
tree | 2d29ee8e070fe47f3160b1963ac45d6d97c18fa8 /activerecord/test | |
parent | 0250c3eca40f5f2b3da698b11ff4f01f58db5a69 (diff) | |
download | rails-ca7b0a0d1a424aec0973fe22c299b8f04e309784.tar.gz rails-ca7b0a0d1a424aec0973fe22c299b8f04e309784.tar.bz2 rails-ca7b0a0d1a424aec0973fe22c299b8f04e309784.zip |
dup is working better
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/base_test.rb | 4 | ||||
-rw-r--r-- | activerecord/test/cases/duplication_test.rb | 43 |
2 files changed, 43 insertions, 4 deletions
diff --git a/activerecord/test/cases/base_test.rb b/activerecord/test/cases/base_test.rb index 26f388ca46..c8efabed30 100644 --- a/activerecord/test/cases/base_test.rb +++ b/activerecord/test/cases/base_test.rb @@ -1443,10 +1443,6 @@ class BasicsTest < ActiveRecord::TestCase ActiveRecord::Base.logger = original_logger end - def test_dup - assert !Minimalistic.new.freeze.dup.frozen? - end - def test_compute_type_success assert_equal Author, ActiveRecord::Base.send(:compute_type, 'Author') end diff --git a/activerecord/test/cases/duplication_test.rb b/activerecord/test/cases/duplication_test.rb new file mode 100644 index 0000000000..610894a03e --- /dev/null +++ b/activerecord/test/cases/duplication_test.rb @@ -0,0 +1,43 @@ +require "cases/helper" +require 'models/topic' + +module ActiveRecord + class DuplicationTest < ActiveRecord::TestCase + fixtures :topics + + def test_dup + assert !Minimalistic.new.freeze.dup.frozen? + end + + def test_dup_not_persisted + topic = Topic.first + duped = topic.dup + + assert !duped.persisted?, 'topic not persisted' + assert duped.new_record?, 'topic is new' + end + + def test_dup_has_no_id + topic = Topic.first + duped = topic.dup + assert_nil duped.id + end + + def test_clone_persisted + topic = Topic.first + cloned = topic.clone + assert cloned.persisted?, 'topic persisted' + assert !cloned.new_record?, 'topic is not new' + end + + def test_clone_keeps_frozen + topic = Topic.first + topic.freeze + + cloned = topic.clone + assert cloned.persisted?, 'topic persisted' + assert !cloned.new_record?, 'topic is not new' + assert cloned.frozen?, 'topic is frozen' + end + end +end |