diff --git a/activerecord/test/cases/associations/has_one_through_associations_test.rb b/activerecord/test/cases/associations/has_one_through_associations_test.rb index 9aef3eb..7304b2c 100644 --- a/activerecord/test/cases/associations/has_one_through_associations_test.rb +++ b/activerecord/test/cases/associations/has_one_through_associations_test.rb @@ -206,4 +206,22 @@ class HasOneThroughAssociationsTest < ActiveRecord::TestCase Club.find(@club.id, :include => :sponsored_member).save! end end + + def test_access_has_one_through_on_new_record_when_through_is_already_set + new_member = Member.new :name => 'Joe Nouveau' + new_member.member_detail = MemberDetail.new + new_member.member_detail.organization = organizations(:discordians) + assert new_member.new_record? + assert_equal organizations(:discordians), new_member.organization + end + + def test_set_has_one_through_on_new_record_when_through_is_already_set + new_member = Member.new :name => 'Joe Nouveau' + new_member.member_detail = MemberDetail.new + new_member.member_detail.organization = organizations(:discordians) + new_member.organization = organizations(:nsa) + assert_equal organizations(:nsa), new_member.organization + assert_equal organizations(:nsa), new_member.member_detail.organization + end + end