diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2006-02-28 20:37:21 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2006-02-28 20:37:21 +0000 |
commit | 4c7555aef78decb8f9d515be72741c273114bc21 (patch) | |
tree | 47a07087bb8da4d218900e14e0dc1e1f6e4f8748 /activerecord/test | |
parent | 17ff70ac84b48ffc437551446814e77f1e0f0428 (diff) | |
download | rails-4c7555aef78decb8f9d515be72741c273114bc21.tar.gz rails-4c7555aef78decb8f9d515be72741c273114bc21.tar.bz2 rails-4c7555aef78decb8f9d515be72741c273114bc21.zip |
Fixed that Base.save should always return false if the save didn't succeed, including if it has halted by before_save's (closes #1861, #2477) [DHH]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3707 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/callbacks_test.rb | 28 |
1 files changed, 5 insertions, 23 deletions
diff --git a/activerecord/test/callbacks_test.rb b/activerecord/test/callbacks_test.rb index c1639c1795..3a4dac90cf 100644 --- a/activerecord/test/callbacks_test.rb +++ b/activerecord/test/callbacks_test.rb @@ -324,39 +324,21 @@ class CallbacksTest < Test::Unit::TestCase def test_before_save_returning_false david = ImmutableDeveloper.find(1) assert david.valid? - assert david.save - assert david.cancelled? - - david = ImmutableDeveloper.find(1) - david.salary = 10_000_000 - assert !david.valid? assert !david.save - assert !david.cancelled? - - david = ImmutableMethodDeveloper.find(1) - assert david.valid? - assert david.save - assert david.cancelled? + assert_raises(ActiveRecord::RecordNotSaved) { david.save! } - david = ImmutableMethodDeveloper.find(1) + david = ImmutableDeveloper.find(1) david.salary = 10_000_000 assert !david.valid? assert !david.save - assert !david.cancelled? + assert_raises(ActiveRecord::RecordInvalid) { david.save! } end def test_before_destroy_returning_false david = ImmutableDeveloper.find(1) - david.destroy - assert david.cancelled? + assert !david.destroy assert_not_nil ImmutableDeveloper.find_by_id(1) - - david = ImmutableMethodDeveloper.find(1) - david.destroy - assert david.cancelled? - assert_not_nil ImmutableMethodDeveloper.find_by_id(1) - end - + end def test_zzz_callback_returning_false # must be run last since we modify CallbackDeveloper david = CallbackDeveloper.find(1) |