class CallbacksWithMethodNamesShouldBeCalled

Public Instance Methods

test_before_validation_and_after_validation_callbacks_should_be_called() click to toggle source
# File activemodel/test/cases/validations/callbacks_test.rb, line 101
def test_before_validation_and_after_validation_callbacks_should_be_called
  d = DogWithMethodCallbacks.new
  d.valid?
  assert_equal ["before_validation_marker", "after_validation_marker"], d.history
end
test_before_validation_and_after_validation_callbacks_should_be_called_in_declared_order() click to toggle source
# File activemodel/test/cases/validations/callbacks_test.rb, line 113
def test_before_validation_and_after_validation_callbacks_should_be_called_in_declared_order
  d = DogWithTwoValidators.new
  d.valid?
  assert_equal ["before_validation_marker1", "before_validation_marker2"], d.history
end
test_before_validation_and_after_validation_callbacks_should_be_called_with_proc() click to toggle source
# File activemodel/test/cases/validations/callbacks_test.rb, line 107
def test_before_validation_and_after_validation_callbacks_should_be_called_with_proc
  d = DogValidatorsAreProc.new
  d.valid?
  assert_equal ["before_validation_marker", "after_validation_marker"], d.history
end
test_further_callbacks_should_be_called_if_after_validation_returns_false() click to toggle source
# File activemodel/test/cases/validations/callbacks_test.rb, line 133
def test_further_callbacks_should_be_called_if_after_validation_returns_false
  d = DogAfterValidatorReturningFalse.new
  d.valid?
  assert_equal ["after_validation_marker"], d.history
end
test_further_callbacks_should_be_called_if_before_validation_returns_false() click to toggle source
# File activemodel/test/cases/validations/callbacks_test.rb, line 126
def test_further_callbacks_should_be_called_if_before_validation_returns_false
  d = DogBeforeValidatorReturningFalse.new
  output = d.valid?
  assert_equal ["before_validation_marker2"], d.history
  assert_equal true, output
end
test_further_callbacks_should_not_be_called_if_before_validation_throws_abort() click to toggle source
# File activemodel/test/cases/validations/callbacks_test.rb, line 119
def test_further_callbacks_should_not_be_called_if_before_validation_throws_abort
  d = DogBeforeValidatorThrowingAbort.new
  output = d.valid?
  assert_equal [], d.history
  assert_equal false, output
end
test_if_condition_is_respected_for_before_validation() click to toggle source
# File activemodel/test/cases/validations/callbacks_test.rb, line 77
def test_if_condition_is_respected_for_before_validation
  d = DogValidatorWithIfCondition.new
  d.valid?
  assert_equal ["before_validation_marker1", "after_validation_marker1"], d.history
end
test_on_condition_is_respected_for_validation_with_matching_context() click to toggle source
# File activemodel/test/cases/validations/callbacks_test.rb, line 83
def test_on_condition_is_respected_for_validation_with_matching_context
  d = DogValidatorWithOnCondition.new
  d.valid?(:create)
  assert_equal ["before_validation_marker", "after_validation_marker"], d.history
end
test_on_condition_is_respected_for_validation_without_context() click to toggle source
# File activemodel/test/cases/validations/callbacks_test.rb, line 95
def test_on_condition_is_respected_for_validation_without_context
  d = DogValidatorWithOnCondition.new
  d.valid?
  assert_equal [], d.history
end
test_on_condition_is_respected_for_validation_without_matching_context() click to toggle source
# File activemodel/test/cases/validations/callbacks_test.rb, line 89
def test_on_condition_is_respected_for_validation_without_matching_context
  d = DogValidatorWithOnCondition.new
  d.valid?(:save)
  assert_equal [], d.history
end
test_validation_test_should_be_done() click to toggle source
# File activemodel/test/cases/validations/callbacks_test.rb, line 139
def test_validation_test_should_be_done
  d = DogWithMissingName.new
  output = d.valid?
  assert_equal ["before_validation_marker"], d.history
  assert_equal false, output
end