mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge pull request #23034 from claudiob/fix-ac-param-as-json
AC::Parameters#at_json: restore Rails 4.2’s value
This commit is contained in:
commit
858b9652ce
2 changed files with 8 additions and 1 deletions
|
@ -109,7 +109,8 @@ module ActionController
|
||||||
cattr_accessor :permit_all_parameters, instance_accessor: false
|
cattr_accessor :permit_all_parameters, instance_accessor: false
|
||||||
cattr_accessor :action_on_unpermitted_parameters, instance_accessor: false
|
cattr_accessor :action_on_unpermitted_parameters, instance_accessor: false
|
||||||
|
|
||||||
delegate :keys, :key?, :has_key?, :empty?, :include?, :inspect, to: :@parameters
|
delegate :keys, :key?, :has_key?, :empty?, :include?, :inspect,
|
||||||
|
:as_json, to: :@parameters
|
||||||
|
|
||||||
# By default, never raise an UnpermittedParameters exception if these
|
# By default, never raise an UnpermittedParameters exception if these
|
||||||
# params are present. The default includes both 'controller' and 'action'
|
# params are present. The default includes both 'controller' and 'action'
|
||||||
|
|
|
@ -27,6 +27,12 @@ class ParametersAccessorsTest < ActiveSupport::TestCase
|
||||||
assert_not @params[:person][:name].permitted?
|
assert_not @params[:person][:name].permitted?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "as_json returns the JSON representation of the parameters hash" do
|
||||||
|
assert_not @params.as_json.key? "parameters"
|
||||||
|
assert_not @params.as_json.key? "permitted"
|
||||||
|
assert @params.as_json.key? "person"
|
||||||
|
end
|
||||||
|
|
||||||
test "each carries permitted status" do
|
test "each carries permitted status" do
|
||||||
@params.permit!
|
@params.permit!
|
||||||
@params.each { |key, value| assert(value.permitted?) if key == "person" }
|
@params.each { |key, value| assert(value.permitted?) if key == "person" }
|
||||||
|
|
Loading…
Reference in a new issue