class OverridingAssociationsTest

Public Instance Methods

test_belongs_to_association_redefinition_reflections_should_differ_and_not_inherited() click to toggle source
# File activerecord/test/cases/associations_test.rb, line 320
def test_belongs_to_association_redefinition_reflections_should_differ_and_not_inherited
  assert_not_equal(
    PeopleList.reflect_on_association(:belongs_to),
    DifferentPeopleList.reflect_on_association(:belongs_to)
  )
end
test_habtm_association_redefinition_callbacks_should_differ_and_not_inherited() click to toggle source
# File activerecord/test/cases/associations_test.rb, line 290
def test_habtm_association_redefinition_callbacks_should_differ_and_not_inherited
  # redeclared association on AR descendant should not inherit callbacks from superclass
  callbacks = PeopleList.before_add_for_has_and_belongs_to_many
  assert_equal(1, callbacks.length)
  callbacks = DifferentPeopleList.before_add_for_has_and_belongs_to_many
  assert_equal([], callbacks)
end
test_habtm_association_redefinition_reflections_should_differ_and_not_inherited() click to toggle source
# File activerecord/test/cases/associations_test.rb, line 306
def test_habtm_association_redefinition_reflections_should_differ_and_not_inherited
  assert_not_equal(
    PeopleList.reflect_on_association(:has_and_belongs_to_many),
    DifferentPeopleList.reflect_on_association(:has_and_belongs_to_many)
  )
end
test_has_many_association_redefinition_callbacks_should_differ_and_not_inherited() click to toggle source
# File activerecord/test/cases/associations_test.rb, line 298
def test_has_many_association_redefinition_callbacks_should_differ_and_not_inherited
  # redeclared association on AR descendant should not inherit callbacks from superclass
  callbacks = PeopleList.before_add_for_has_many
  assert_equal(1, callbacks.length)
  callbacks = DifferentPeopleList.before_add_for_has_many
  assert_equal([], callbacks)
end
test_has_many_association_redefinition_reflections_should_differ_and_not_inherited() click to toggle source
# File activerecord/test/cases/associations_test.rb, line 313
def test_has_many_association_redefinition_reflections_should_differ_and_not_inherited
  assert_not_equal(
    PeopleList.reflect_on_association(:has_many),
    DifferentPeopleList.reflect_on_association(:has_many)
  )
end
test_has_one_association_redefinition_reflections_should_differ_and_not_inherited() click to toggle source
# File activerecord/test/cases/associations_test.rb, line 327
def test_has_one_association_redefinition_reflections_should_differ_and_not_inherited
  assert_not_equal(
    PeopleList.reflect_on_association(:has_one),
    DifferentPeopleList.reflect_on_association(:has_one)
  )
end
test_requires_symbol_argument() click to toggle source
# File activerecord/test/cases/associations_test.rb, line 334
def test_requires_symbol_argument
  assert_raises ArgumentError do
    Class.new(Post) do
      belongs_to "author"
    end
  end
end