aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--activerecord/lib/active_record/base.rb1
-rw-r--r--activerecord/test/cases/base_test.rb8
2 files changed, 9 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index 3f81ca7555..3a7db97a6a 100644
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -1433,6 +1433,7 @@ module ActiveRecord #:nodoc:
end
clear_aggregation_cache
+ clear_association_cache
@attributes_cache = {}
@new_record = true
ensure_proper_type
diff --git a/activerecord/test/cases/base_test.rb b/activerecord/test/cases/base_test.rb
index 7c74d87b61..c24a494c85 100644
--- a/activerecord/test/cases/base_test.rb
+++ b/activerecord/test/cases/base_test.rb
@@ -1401,6 +1401,14 @@ class BasicsTest < ActiveRecord::TestCase
assert_not_equal clone.id, dev.id
end
+ def test_clone_does_not_clone_associations
+ author = authors(:david)
+ assert_not_equal [], author.posts
+
+ author_clone = author.clone
+ assert_equal [], author_clone.posts
+ end
+
def test_clone_preserves_subtype
clone = nil
assert_nothing_raised { clone = Company.find(3).clone }