Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

test case for #8125 => passes

  • Loading branch information...
commit cfb140a732e64cbd16b804ce60ac8cfe2a22df1e 1 parent 12d6d3a
@senny authored
View
10 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)
View
1  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
Please sign in to comment.
Something went wrong with that request. Please try again.