1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/activemodel/test/cases
Yoshiyuki Hirano 470d0e459f Fix validation callbacks on multiple context
I found a bug that validation callbacks don't fire on multiple context.
So I've fixed it.

Example:

```ruby
class Dog
  include ActiveModel::Validations
  include ActiveModel::Validations::Callbacks

  attr_accessor :history

  def initialize
    @history = []
  end

  before_validation :set_before_validation_on_a, on: :a
  before_validation :set_before_validation_on_b, on: :b
  after_validation :set_after_validation_on_a, on: :a
  after_validation :set_after_validation_on_b, on: :b

  def set_before_validation_on_a; history << "before_validation on a"; end
  def set_before_validation_on_b; history << "before_validation on b"; end
  def set_after_validation_on_a;  history << "after_validation on a" ; end
  def set_after_validation_on_b;  history << "after_validation on b" ; end
end
```

Before:

```
d = Dog.new
d.valid?([:a, :b])
d.history # []
```

After:

```
d = Dog.new
d.valid?([:a, :b])
d.history # ["before_validation on a", "before_validation on b", "after_validation on a", "after_validation on b"]
```
2017-12-20 00:27:19 +09:00
..
serializers Use frozen string literal in activemodel/ 2017-07-16 20:11:16 +03:00
type Suppress warning: BigDecimal.new is deprecated in Active Model 2017-12-14 19:00:00 +00:00
validations Fix validation callbacks on multiple context 2017-12-20 00:27:19 +09:00
attribute_assignment_test.rb Use frozen string literal in activemodel/ 2017-07-16 20:11:16 +03:00
attribute_methods_test.rb Merge pull request #29788 from kamipo/remove_unused_mutex_m 2017-07-17 13:54:37 -04:00
attribute_set_test.rb Change how AttributeSet::Builder receives its defaults 2017-11-27 14:06:51 -07:00
attribute_test.rb Move Attribute and AttributeSet to ActiveModel 2017-11-09 14:29:39 -05:00
attributes_dirty_test.rb Move Attribute and AttributeSet to ActiveModel 2017-11-09 14:29:39 -05:00
attributes_test.rb Suppress warning: BigDecimal.new is deprecated in Active Model 2017-12-14 19:00:00 +00:00
callbacks_test.rb Use frozen string literal in activemodel/ 2017-07-16 20:11:16 +03:00
conversion_test.rb Use frozen string literal in activemodel/ 2017-07-16 20:11:16 +03:00
dirty_test.rb Move Attribute and AttributeSet to ActiveModel 2017-11-09 14:29:39 -05:00
errors_test.rb fix bug on added? method 2017-11-13 17:27:47 +01:00
forbidden_attributes_protection_test.rb Use frozen string literal in activemodel/ 2017-07-16 20:11:16 +03:00
helper.rb Use frozen string literal in activemodel/ 2017-07-16 20:11:16 +03:00
lint_test.rb Use frozen string literal in activemodel/ 2017-07-16 20:11:16 +03:00
model_test.rb Use frozen string literal in activemodel/ 2017-07-16 20:11:16 +03:00
naming_test.rb Use frozen string literal in activemodel/ 2017-07-16 20:11:16 +03:00
railtie_test.rb Use frozen string literal in activemodel/ 2017-07-16 20:11:16 +03:00
secure_password_test.rb Use frozen string literal in activemodel/ 2017-07-16 20:11:16 +03:00
serialization_test.rb Use frozen string literal in activemodel/ 2017-07-16 20:11:16 +03:00
translation_test.rb Use frozen string literal in activemodel/ 2017-07-16 20:11:16 +03:00
validations_test.rb Use frozen string literal in activemodel/ 2017-07-16 20:11:16 +03:00