aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test
diff options
context:
space:
mode:
authorNeeraj Singh <neerajdotname@gmail.com>2010-12-17 11:04:20 +0800
committerJosé Valim <jose.valim@gmail.com>2010-12-29 05:32:23 +0800
commit27d0d4fffdb62d221e124b67b7ee3de6bfa1893b (patch)
treeb2bf45c76a05402e55b5d72e565b8b05a98b4cf1 /activesupport/test
parent6b43a3a6271faa81ee53bd798b290320217e3262 (diff)
downloadrails-27d0d4fffdb62d221e124b67b7ee3de6bfa1893b.tar.gz
rails-27d0d4fffdb62d221e124b67b7ee3de6bfa1893b.tar.bz2
rails-27d0d4fffdb62d221e124b67b7ee3de6bfa1893b.zip
while defining callbacks option :rescuable => true
can be passed. There were no tests for this case. This patch adds a test for :rescuable => true option.
Diffstat (limited to 'activesupport/test')
-rw-r--r--activesupport/test/callbacks_test.rb31
1 files changed, 30 insertions, 1 deletions
diff --git a/activesupport/test/callbacks_test.rb b/activesupport/test/callbacks_test.rb
index 51b28b6a43..c89b03e243 100644
--- a/activesupport/test/callbacks_test.rb
+++ b/activesupport/test/callbacks_test.rb
@@ -3,6 +3,27 @@ require 'test/unit'
require 'active_support'
module CallbacksTest
+ class Phone
+ include ActiveSupport::Callbacks
+ define_callbacks :save, :rescuable => true
+
+ set_callback :save, :before, :before_save1
+ set_callback :save, :after, :after_save1
+
+ def before_save1; self.history << :before; end
+ def after_save1; self.history << :after; end
+
+ def save
+ self.send(:_run_save_callbacks) do
+ raise 'boom'
+ end
+ end
+
+ def history
+ @history ||= []
+ end
+ end
+
class Record
include ActiveSupport::Callbacks
@@ -338,6 +359,14 @@ module CallbacksTest
end
class CallbacksTest < Test::Unit::TestCase
+ def test_save_phone
+ phone = Phone.new
+ assert_raise RuntimeError do
+ phone.save
+ end
+ assert_equal [:before, :after], phone.history
+ end
+
def test_save_person
person = Person.new
assert_equal [], person.history
@@ -573,5 +602,5 @@ module CallbacksTest
], writer.history
end
end
-
+
end