aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2010-11-23 11:30:14 -0800
committerAaron Patterson <aaron.patterson@gmail.com>2010-11-23 14:29:05 -0800
commit93d78b831831a1c8e324d4c5404b99e81fe77725 (patch)
tree7b9d090862c70cf097793b9826b0272edfcd967b /activerecord/test/cases
parent6a8f1b8b402b31ae43872c9d1f37b931c85799e7 (diff)
downloadrails-93d78b831831a1c8e324d4c5404b99e81fe77725.tar.gz
rails-93d78b831831a1c8e324d4c5404b99e81fe77725.tar.bz2
rails-93d78b831831a1c8e324d4c5404b99e81fe77725.zip
fixing more dup tests
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r--activerecord/test/cases/base_test.rb43
1 files changed, 22 insertions, 21 deletions
diff --git a/activerecord/test/cases/base_test.rb b/activerecord/test/cases/base_test.rb
index c8efabed30..e3f4f2bd08 100644
--- a/activerecord/test/cases/base_test.rb
+++ b/activerecord/test/cases/base_test.rb
@@ -669,36 +669,36 @@ class BasicsTest < ActiveRecord::TestCase
assert_equal true, Topic.find(1).persisted?
end
- def test_clone
+ def test_dup
topic = Topic.find(1)
- cloned_topic = nil
- assert_nothing_raised { cloned_topic = topic.clone }
- assert_equal topic.title, cloned_topic.title
- assert !cloned_topic.persisted?
+ duped_topic = nil
+ assert_nothing_raised { duped_topic = topic.dup }
+ assert_equal topic.title, duped_topic.title
+ assert !duped_topic.persisted?
- # test if the attributes have been cloned
+ # test if the attributes have been duped
topic.title = "a"
- cloned_topic.title = "b"
+ duped_topic.title = "b"
assert_equal "a", topic.title
- assert_equal "b", cloned_topic.title
+ assert_equal "b", duped_topic.title
- # test if the attribute values have been cloned
+ # test if the attribute values have been duped
topic.title = {"a" => "b"}
- cloned_topic = topic.clone
- cloned_topic.title["a"] = "c"
+ duped_topic = topic.dup
+ duped_topic.title["a"] = "c"
assert_equal "b", topic.title["a"]
- # test if attributes set as part of after_initialize are cloned correctly
- assert_equal topic.author_email_address, cloned_topic.author_email_address
+ # test if attributes set as part of after_initialize are duped correctly
+ assert_equal topic.author_email_address, duped_topic.author_email_address
# test if saved clone object differs from original
- cloned_topic.save
- assert cloned_topic.persisted?
- assert_not_equal cloned_topic.id, topic.id
+ duped_topic.save
+ assert duped_topic.persisted?
+ assert_not_equal duped_topic.id, topic.id
- cloned_topic.reload
+ duped_topic.reload
# FIXME: I think this is poor behavior, and will fix it with #5686
- assert_equal({'a' => 'c'}.to_s, cloned_topic.title)
+ assert_equal({'a' => 'c'}.to_s, duped_topic.title)
end
def test_clone_with_aggregate_of_same_name_as_attribute
@@ -721,12 +721,13 @@ class BasicsTest < ActiveRecord::TestCase
assert_not_equal clone.id, dev.id
end
- def test_clone_does_not_clone_associations
+ def test_dup_does_not_copy_associations
author = authors(:david)
assert_not_equal [], author.posts
+ author.send(:clear_association_cache)
- author_clone = author.clone
- assert_equal [], author_clone.posts
+ author_dup = author.dup
+ assert_equal [], author_dup.posts
end
def test_clone_preserves_subtype