1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Revert "Dupping a CollectionProxy should dup the load_target"

I incorrectly changed behavior of `dup`. Reading the original issue I
thought that `dup` should retain the original contents of the record
and it's associations but it is in fact supposed to be a copy as if a
record had been reinitialized.

This reverts commit ca8c21df0f.
This commit is contained in:
eileencodes 2017-02-28 13:45:01 -05:00
parent 219402901f
commit b8e9dc489b
2 changed files with 0 additions and 12 deletions

View file

@ -36,10 +36,6 @@ module ActiveRecord
merge! association.scope(nullify: false) merge! association.scope(nullify: false)
end end
def initialize_dup(other) # :nodoc:
@association = @association.deep_dup
end
def target def target
@association.target @association.target
end end

View file

@ -2056,14 +2056,6 @@ class HasManyAssociationsTest < ActiveRecord::TestCase
assert_not_equal target.object_id, ary.object_id assert_not_equal target.object_id, ary.object_id
end end
def test_dup_should_dup_load_target
original = topics(:first).replies
dupped = topics(:first).replies.dup
assert_not_equal original.object_id, dupped.object_id
assert_not_equal original.load_target.object_id, dupped.load_target.object_id
end
def test_merging_with_custom_attribute_writer def test_merging_with_custom_attribute_writer
bulb = Bulb.new(:color => "red") bulb = Bulb.new(:color => "red")
assert_equal "RED!", bulb.color assert_equal "RED!", bulb.color