mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Remove test ordering bug by using another class
This commit is contained in:
parent
3bd85e2748
commit
34497c0b36
1 changed files with 7 additions and 4 deletions
|
@ -43,6 +43,11 @@ class CallbackDeveloper < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
class CallbackDeveloperWithFalseValidation < CallbackDeveloper
|
||||
before_validation proc { |model| model.history << [:before_validation, :returning_false]; return false }
|
||||
before_validation proc { |model| model.history << [:before_validation, :should_never_get_here] }
|
||||
end
|
||||
|
||||
class ParentDeveloper < ActiveRecord::Base
|
||||
set_table_name 'developers'
|
||||
attr_accessor :after_save_called
|
||||
|
@ -437,10 +442,8 @@ class CallbacksTest < ActiveRecord::TestCase
|
|||
end
|
||||
private :assert_save_callbacks_not_called
|
||||
|
||||
def test_zzz_callback_returning_false # must be run last since we modify CallbackDeveloper
|
||||
david = CallbackDeveloper.find(1)
|
||||
CallbackDeveloper.before_validation proc { |model| model.history << [:before_validation, :returning_false]; return false }
|
||||
CallbackDeveloper.before_validation proc { |model| model.history << [:before_validation, :should_never_get_here] }
|
||||
def test_callback_returning_false
|
||||
david = CallbackDeveloperWithFalseValidation.find(1)
|
||||
david.save
|
||||
assert_equal [
|
||||
[ :after_find, :method ],
|
||||
|
|
Loading…
Reference in a new issue