class InverseBelongsToTests
Public Instance Methods
test_should_not_try_to_set_inverse_instances_when_the_inverse_is_a_has_many()
click to toggle source
# File activerecord/test/cases/associations/inverse_associations_test.rb, line 588 def test_should_not_try_to_set_inverse_instances_when_the_inverse_is_a_has_many i = interests(:trainspotting) m = i.man assert_not_nil m.interests iz = m.interests.detect { |_iz| _iz.id == i.id } assert_not_nil iz assert_equal i.topic, iz.topic, "Interest topics should be the same before changes to child" i.topic = "Eating cheese with a spoon" assert_not_equal i.topic, iz.topic, "Interest topics should not be the same after changes to child" iz.topic = "Cow tipping" assert_not_equal i.topic, iz.topic, "Interest topics should not be the same after changes to parent-owned instance" end
test_trying_to_use_inverses_that_dont_exist_should_raise_an_error()
click to toggle source
# File activerecord/test/cases/associations/inverse_associations_test.rb, line 613 def test_trying_to_use_inverses_that_dont_exist_should_raise_an_error assert_raise(ActiveRecord::InverseOfAssociationNotFoundError) { Face.first.horrible_man } end