diff options
author | Matt Jones <al2o3cr@gmail.com> | 2008-12-02 16:21:21 -0500 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2008-12-18 19:19:36 +0000 |
commit | a9422cc1db9501a80ecf2c25a5d3b0c4f4f32763 (patch) | |
tree | 27f933f524f033434448fd953cf24285c36d007f /activerecord/test/cases | |
parent | 8326b95169ae6af3b81f5596107fef9db4bcbbb0 (diff) | |
download | rails-a9422cc1db9501a80ecf2c25a5d3b0c4f4f32763.tar.gz rails-a9422cc1db9501a80ecf2c25a5d3b0c4f4f32763.tar.bz2 rails-a9422cc1db9501a80ecf2c25a5d3b0c4f4f32763.zip |
Fix preloading of has_one :through associations on belongs_to [#1507 state:resolved]
Signed-off-by: Frederick Cheung <frederick.cheung@gmail.com>
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/associations/has_one_through_associations_test.rb | 17 |
1 files changed, 16 insertions, 1 deletions
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 7d418de965..f65d76e2ce 100644 --- a/activerecord/test/cases/associations/has_one_through_associations_test.rb +++ b/activerecord/test/cases/associations/has_one_through_associations_test.rb @@ -1,5 +1,6 @@ require "cases/helper" require 'models/club' +require 'models/member_type' require 'models/member' require 'models/membership' require 'models/sponsor' @@ -7,7 +8,7 @@ require 'models/organization' require 'models/member_detail' class HasOneThroughAssociationsTest < ActiveRecord::TestCase - fixtures :members, :clubs, :memberships, :sponsors, :organizations + fixtures :member_types, :members, :clubs, :memberships, :sponsors, :organizations def setup @member = members(:groucho) @@ -158,4 +159,18 @@ class HasOneThroughAssociationsTest < ActiveRecord::TestCase assert @new_organization.members.include?(@member) end + def test_preloading_has_one_through_on_belongs_to + assert_not_nil @member.member_type + @organization = organizations(:nsa) + @member_detail = MemberDetail.new + @member.member_detail = @member_detail + @member.organization = @organization + @member_details = assert_queries(3) do + MemberDetail.find(:all, :include => :member_type) + end + @new_detail = @member_details[0] + assert @new_detail.loaded_member_type? + assert_not_nil assert_no_queries { @new_detail.member_type } + end + end |