From 60b23ea1da1c119eaab6d07e5a03cf3b5d5577d4 Mon Sep 17 00:00:00 2001 From: Jon Leighton Date: Sat, 14 May 2011 19:40:24 +0100 Subject: CollectionAssociation#merge_target_lists should write to the underlying attributes when copying, rather than using the assignment method --- .../test/cases/associations/has_many_associations_test.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'activerecord/test/cases/associations') diff --git a/activerecord/test/cases/associations/has_many_associations_test.rb b/activerecord/test/cases/associations/has_many_associations_test.rb index b149f5912f..0e33fa9c8e 100644 --- a/activerecord/test/cases/associations/has_many_associations_test.rb +++ b/activerecord/test/cases/associations/has_many_associations_test.rb @@ -1445,4 +1445,14 @@ class HasManyAssociationsTest < ActiveRecord::TestCase assert_not_equal target.object_id, ary.object_id end + + def test_merging_with_custom_attribute_writer + bulb = Bulb.new(:color => "red") + assert_equal "RED!", bulb.color + + car = Car.create! + car.bulbs << bulb + + assert_equal "RED!", car.bulbs.to_a.first.color + end end -- cgit v1.2.3