aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/associations/has_many_associations_test.rb
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2011-06-30 22:41:18 +0100
committerJon Leighton <j@jonathanleighton.com>2011-06-30 23:39:58 +0100
commit0e225ec583db523a8b7da332eaf689149ed60447 (patch)
treebb18c8a7b672eb7545c36daba2aba2c0a3ce46c0 /activerecord/test/cases/associations/has_many_associations_test.rb
parent6a283d598f243197375266c8b981b66f1b5f10c5 (diff)
downloadrails-0e225ec583db523a8b7da332eaf689149ed60447.tar.gz
rails-0e225ec583db523a8b7da332eaf689149ed60447.tar.bz2
rails-0e225ec583db523a8b7da332eaf689149ed60447.zip
Assign the association attributes to the associated record before the before_initialize callback of the record runs. Fixes #1842.
Diffstat (limited to 'activerecord/test/cases/associations/has_many_associations_test.rb')
-rw-r--r--activerecord/test/cases/associations/has_many_associations_test.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/activerecord/test/cases/associations/has_many_associations_test.rb b/activerecord/test/cases/associations/has_many_associations_test.rb
index 9af1f7249f..7e331658a3 100644
--- a/activerecord/test/cases/associations/has_many_associations_test.rb
+++ b/activerecord/test/cases/associations/has_many_associations_test.rb
@@ -1557,4 +1557,11 @@ class HasManyAssociationsTest < ActiveRecord::TestCase
assert_equal 1, contract.hi_count
assert_equal 1, contract.bye_count
end
+
+ def test_association_attributes_are_available_to_after_initialize
+ car = Car.create(:name => 'honda')
+ bulb = car.bulbs.build
+
+ assert_equal car.id, bulb.attributes_after_initialize['car_id']
+ end
end