diff options
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/callbacks_test.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/activerecord/test/callbacks_test.rb b/activerecord/test/callbacks_test.rb index 3a4dac90cf..fa2e3da774 100644 --- a/activerecord/test/callbacks_test.rb +++ b/activerecord/test/callbacks_test.rb @@ -109,6 +109,13 @@ class ImmutableMethodDeveloper < ActiveRecord::Base end end +class CallbackCancellationDeveloper < ActiveRecord::Base + set_table_name 'developers' + def before_create + false + end +end + class CallbacksTest < Test::Unit::TestCase fixtures :developers @@ -334,6 +341,12 @@ class CallbacksTest < Test::Unit::TestCase assert_raises(ActiveRecord::RecordInvalid) { david.save! } end + def test_before_create_returning_false + someone = CallbackCancellationDeveloper.new + assert someone.valid? + assert !someone.save + end + def test_before_destroy_returning_false david = ImmutableDeveloper.find(1) assert !david.destroy |