Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alias ActionController::Parameters except as without #47687

Merged
merged 1 commit into from
Mar 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions actionpack/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
* Add `without` as an alias of `except` on `ActiveController::Parameters`.

*Hidde-Jan Jongsma*

* Expand search field on `rails/info/routes` to also search **route name**, **http verb** and **controller#action**.

*Jason Kotchoff*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -734,6 +734,7 @@ def slice!(*keys)
def except(*keys)
new_instance_with_inherited_permitted_status(@parameters.except(*keys))
end
alias_method :without, :except

# Removes and returns the key/value pairs matching the given keys.
#
Expand Down
11 changes: 11 additions & 0 deletions actionpack/test/controller/parameters/accessors_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,17 @@ class ParametersAccessorsTest < ActiveSupport::TestCase
assert_not_predicate @params[:person].except(:name), :permitted?
end

test "without retains permitted status" do
@params.permit!
assert_predicate @params.without(:person), :permitted?
assert_predicate @params[:person].without(:name), :permitted?
end

test "without retains unpermitted status" do
assert_not_predicate @params.without(:person), :permitted?
assert_not_predicate @params[:person].without(:name), :permitted?
end

test "exclude? returns true if the given key is not present in the params" do
assert @params.exclude?(:address)
end
Expand Down