aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/associations/has_one_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_one_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_one_associations_test.rb')
-rw-r--r--activerecord/test/cases/associations/has_one_associations_test.rb7
1 files changed, 7 insertions, 0 deletions
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