aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/controller
diff options
context:
space:
mode:
authorSergio Romano <sromano@stelladot.com>2014-06-13 14:42:38 -0300
committerSergio Romano <sromano@stelladot.com>2014-06-13 14:42:38 -0300
commit540d1535316d6ecbe755ee66dfcbc23dc0bde3a5 (patch)
tree4aa86144d8bb15ad872860ed82ae88513c869e5c /actionpack/test/controller
parent0bfdf4087047cf7ef72fa10d07baecadefc53b70 (diff)
downloadrails-540d1535316d6ecbe755ee66dfcbc23dc0bde3a5.tar.gz
rails-540d1535316d6ecbe755ee66dfcbc23dc0bde3a5.tar.bz2
rails-540d1535316d6ecbe755ee66dfcbc23dc0bde3a5.zip
ActionController::Parameters#require now accepts FalseClass values
Fixes #15685.
Diffstat (limited to 'actionpack/test/controller')
-rw-r--r--actionpack/test/controller/required_params_test.rb18
1 files changed, 17 insertions, 1 deletions
diff --git a/actionpack/test/controller/required_params_test.rb b/actionpack/test/controller/required_params_test.rb
index 25d0337212..da80888b96 100644
--- a/actionpack/test/controller/required_params_test.rb
+++ b/actionpack/test/controller/required_params_test.rb
@@ -24,10 +24,26 @@ class ActionControllerRequiredParamsTest < ActionController::TestCase
post :create, { book: { name: "Mjallo!" } }
assert_response :ok
end
+
+ test "required parameters with false value will not raise" do
+ post :create, { book: { name: false } }
+ assert_response :ok
+ end
end
class ParametersRequireTest < ActiveSupport::TestCase
- test "required parameters must be present not merely not nil" do
+
+ test "required parameters should accept and return false value" do
+ assert(!ActionController::Parameters.new(person: false).require(:person))
+ end
+
+ test "required parameters must not be nil" do
+ assert_raises(ActionController::ParameterMissing) do
+ ActionController::Parameters.new(person: nil).require(:person)
+ end
+ end
+
+ test "required parameters must not be empty" do
assert_raises(ActionController::ParameterMissing) do
ActionController::Parameters.new(person: {}).require(:person)
end