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
|
||||||
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
|
class ParentDeveloper < ActiveRecord::Base
|
||||||
set_table_name 'developers'
|
set_table_name 'developers'
|
||||||
attr_accessor :after_save_called
|
attr_accessor :after_save_called
|
||||||
|
@ -437,10 +442,8 @@ class CallbacksTest < ActiveRecord::TestCase
|
||||||
end
|
end
|
||||||
private :assert_save_callbacks_not_called
|
private :assert_save_callbacks_not_called
|
||||||
|
|
||||||
def test_zzz_callback_returning_false # must be run last since we modify CallbackDeveloper
|
def test_callback_returning_false
|
||||||
david = CallbackDeveloper.find(1)
|
david = CallbackDeveloperWithFalseValidation.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] }
|
|
||||||
david.save
|
david.save
|
||||||
assert_equal [
|
assert_equal [
|
||||||
[ :after_find, :method ],
|
[ :after_find, :method ],
|
||||||
|
|
Loading…
Reference in a new issue