From 0e225ec583db523a8b7da332eaf689149ed60447 Mon Sep 17 00:00:00 2001 From: Jon Leighton Date: Thu, 30 Jun 2011 22:41:18 +0100 Subject: Assign the association attributes to the associated record before the before_initialize callback of the record runs. Fixes #1842. --- activerecord/test/cases/associations/has_one_associations_test.rb | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'activerecord/test/cases/associations/has_one_associations_test.rb') diff --git a/activerecord/test/cases/associations/has_one_associations_test.rb b/activerecord/test/cases/associations/has_one_associations_test.rb index 299688d840..a1d0dafa57 100644 --- a/activerecord/test/cases/associations/has_one_associations_test.rb +++ b/activerecord/test/cases/associations/has_one_associations_test.rb @@ -438,4 +438,11 @@ class HasOneAssociationsTest < ActiveRecord::TestCase bulb = car.create_bulb!{ |b| b.color = 'Red' } assert_equal 'RED!', bulb.color end + + def test_association_attributes_are_available_to_after_initialize + car = Car.create(:name => 'honda') + bulb = car.create_bulb + + assert_equal car.id, bulb.attributes_after_initialize['car_id'] + end end -- cgit v1.2.3