aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/transaction_callbacks_test.rb
diff options
context:
space:
mode:
authorCarol Nichols <carol.nichols@gmail.com>2014-12-07 22:13:17 -0500
committerCarol Nichols <carol.nichols@gmail.com>2014-12-07 22:16:00 -0500
commitffce60e1280a4a1262f66660cd1540f424848157 (patch)
tree9c89879d0c1ddc0d9085d7e707126181e4907c2b /activerecord/test/cases/transaction_callbacks_test.rb
parent9eb4869f80107be19b6d161a7f2e05449afee85a (diff)
downloadrails-ffce60e1280a4a1262f66660cd1540f424848157.tar.gz
rails-ffce60e1280a4a1262f66660cd1540f424848157.tar.bz2
rails-ffce60e1280a4a1262f66660cd1540f424848157.zip
Make error message clearer that :on requires a symbol, not a string
The validation added in 5a3dc8092d19c816b0b1203945639cb91d065847 will reject values for the `:on` option for after_commit and after_rollback callbacks that are string values like `"create"`. However, the error message says ":on conditions for after_commit and after_rollback callbacks have to be one of create,destroy,update". That looks like a string value *would* be valid. This commit changes the error message to say ":on conditions for after_commit and after_rollback callbacks have to be one of [:create, :destroy, :update]", making it clearer that symbols are required.
Diffstat (limited to 'activerecord/test/cases/transaction_callbacks_test.rb')
-rw-r--r--activerecord/test/cases/transaction_callbacks_test.rb4
1 files changed, 4 insertions, 0 deletions
diff --git a/activerecord/test/cases/transaction_callbacks_test.rb b/activerecord/test/cases/transaction_callbacks_test.rb
index b5ac1bdaf9..0f5caa52e3 100644
--- a/activerecord/test/cases/transaction_callbacks_test.rb
+++ b/activerecord/test/cases/transaction_callbacks_test.rb
@@ -371,10 +371,14 @@ class TransactionCallbacksTest < ActiveRecord::TestCase
def test_after_rollback_callbacks_should_validate_on_condition
assert_raise(ArgumentError) { Topic.after_rollback(on: :save) }
+ e = assert_raise(ArgumentError) { Topic.after_rollback(on: 'create') }
+ assert_match(/:on conditions for after_commit and after_rollback callbacks have to be one of \[:create, :destroy, :update\]/, e.message)
end
def test_after_commit_callbacks_should_validate_on_condition
assert_raise(ArgumentError) { Topic.after_commit(on: :save) }
+ e = assert_raise(ArgumentError) { Topic.after_commit(on: 'create') }
+ assert_match(/:on conditions for after_commit and after_rollback callbacks have to be one of \[:create, :destroy, :update\]/, e.message)
end
def test_saving_a_record_with_a_belongs_to_that_specifies_touching_the_parent_should_call_callbacks_on_the_parent_object