diff options
Diffstat (limited to 'actionpack/test/controller/parameters')
-rw-r--r-- | actionpack/test/controller/parameters/raise_on_unpermitted_params_test.rb | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/actionpack/test/controller/parameters/raise_on_unpermitted_params_test.rb b/actionpack/test/controller/parameters/raise_on_unpermitted_params_test.rb new file mode 100644 index 0000000000..51bbc9c1b1 --- /dev/null +++ b/actionpack/test/controller/parameters/raise_on_unpermitted_params_test.rb @@ -0,0 +1,33 @@ +require 'abstract_unit' +require 'action_controller/metal/strong_parameters' + +class RaiseOnUnpermittedParamsTest < ActiveSupport::TestCase + def setup + ActionController::Parameters.raise_on_unexpected = true + end + + def teardown + ActionController::Parameters.raise_on_unexpected = false + end + + test "raises on unexpected params" do + params = ActionController::Parameters.new({ + book: { pages: 65 }, + fishing: "Turnips" + }) + + assert_raises(ActionController::UnexpectedParameters) do + params.permit(book: [:pages]) + end + end + + test "raises on unexpected nested params" do + params = ActionController::Parameters.new({ + book: { pages: 65, title: "Green Cats and where to find then." } + }) + + assert_raises(ActionController::UnexpectedParameters) do + params.permit(book: [:pages]) + end + end +end
\ No newline at end of file |