aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/callbacks_test.rb
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2018-07-23 04:14:59 +0900
committerRyuta Kamizono <kamipo@gmail.com>2018-07-23 04:19:37 +0900
commita4398e412c042b297039cc216f6536b0c048bd9c (patch)
treea7eab8ca30ba593d86480b058331a5279b111364 /activerecord/test/cases/callbacks_test.rb
parent97321956e6c2d2bae1bf6f76fce5bfb909ab58b0 (diff)
parentdfb0e4b3dc94860e6d484385d31fd399d33dac92 (diff)
downloadrails-a4398e412c042b297039cc216f6536b0c048bd9c.tar.gz
rails-a4398e412c042b297039cc216f6536b0c048bd9c.tar.bz2
rails-a4398e412c042b297039cc216f6536b0c048bd9c.zip
Merge pull request #30919 from seanlinsley/17622-before_save_strict_arguments
Add strict argument checking to ActiveRecord callbacks
Diffstat (limited to 'activerecord/test/cases/callbacks_test.rb')
-rw-r--r--activerecord/test/cases/callbacks_test.rb27
1 files changed, 27 insertions, 0 deletions
diff --git a/activerecord/test/cases/callbacks_test.rb b/activerecord/test/cases/callbacks_test.rb
index b9ba51c730..253c3099d6 100644
--- a/activerecord/test/cases/callbacks_test.rb
+++ b/activerecord/test/cases/callbacks_test.rb
@@ -476,4 +476,31 @@ class CallbacksTest < ActiveRecord::TestCase
child.save
assert child.after_save_called
end
+
+ def test_before_save_doesnt_allow_on_option
+ exception = assert_raises ArgumentError do
+ Class.new(ActiveRecord::Base) do
+ before_save(on: :create) {}
+ end
+ end
+ assert_equal "Unknown key: :on. Valid keys are: :if, :unless, :prepend", exception.message
+ end
+
+ def test_around_save_doesnt_allow_on_option
+ exception = assert_raises ArgumentError do
+ Class.new(ActiveRecord::Base) do
+ around_save(on: :create) {}
+ end
+ end
+ assert_equal "Unknown key: :on. Valid keys are: :if, :unless, :prepend", exception.message
+ end
+
+ def test_after_save_doesnt_allow_on_option
+ exception = assert_raises ArgumentError do
+ Class.new(ActiveRecord::Base) do
+ after_save(on: :create) {}
+ end
+ end
+ assert_equal "Unknown key: :on. Valid keys are: :if, :unless, :prepend", exception.message
+ end
end