From cfb140a732e64cbd16b804ce60ac8cfe2a22df1e Mon Sep 17 00:00:00 2001 From: Yves Senn Date: Sun, 11 Nov 2012 15:24:50 +0100 Subject: [PATCH] test case for #8125 => passes --- .../cases/associations/inverse_associations_test.rb | 10 +++++++++- activerecord/test/models/man.rb | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/activerecord/test/cases/associations/inverse_associations_test.rb b/activerecord/test/cases/associations/inverse_associations_test.rb index 8c9b4fb921bfa..8cb584e7d1994 100644 --- a/activerecord/test/cases/associations/inverse_associations_test.rb +++ b/activerecord/test/cases/associations/inverse_associations_test.rb @@ -164,7 +164,15 @@ def test_trying_to_use_inverses_that_dont_exist_should_raise_an_error end class InverseHasManyTests < ActiveRecord::TestCase - fixtures :men, :interests + fixtures :men, :interests, :zines + + def test_inverse_of_and_association_ids_works_with_through_association + peter = Man.new(:zine_ids => [zines(:staying_in).id, zines(:going_out).id]) + assert_difference 'peter.interests.count', 2 do + peter.save! + end + assert_equal 2, peter.zines.count + end def test_parent_instance_should_be_shared_with_every_child_on_find m = men(:gordon) diff --git a/activerecord/test/models/man.rb b/activerecord/test/models/man.rb index 4bff92dc98bce..91ea5266ab13a 100644 --- a/activerecord/test/models/man.rb +++ b/activerecord/test/models/man.rb @@ -2,6 +2,7 @@ class Man < ActiveRecord::Base has_one :face, :inverse_of => :man has_one :polymorphic_face, :class_name => 'Face', :as => :polymorphic_man, :inverse_of => :polymorphic_man has_many :interests, :inverse_of => :man + has_many :zines, :through => :interests has_many :polymorphic_interests, :class_name => 'Interest', :as => :polymorphic_man, :inverse_of => :polymorphic_man # These are "broken" inverse_of associations for the purposes of testing has_one :dirty_face, :class_name => 'Face', :inverse_of => :dirty_man