aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/controller
diff options
context:
space:
mode:
authorBenjamin Quorning <bquorning@zendesk.com>2012-11-06 21:30:12 +0100
committerBenjamin Quorning <bquorning@zendesk.com>2012-11-06 21:30:12 +0100
commit478d80fd5788a4b3e7c8482bfd3713eef7d00884 (patch)
tree97bddf61725f8e2a31cbc8497c12e4b182992038 /actionpack/test/controller
parent1a0f14e0453d3a36f134989752721292aed54892 (diff)
downloadrails-478d80fd5788a4b3e7c8482bfd3713eef7d00884.tar.gz
rails-478d80fd5788a4b3e7c8482bfd3713eef7d00884.tar.bz2
rails-478d80fd5788a4b3e7c8482bfd3713eef7d00884.zip
Test that permitted? is sticky on accessors, mutators, and merges
Diffstat (limited to 'actionpack/test/controller')
-rw-r--r--actionpack/test/controller/parameters/parameters_permit_test.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/actionpack/test/controller/parameters/parameters_permit_test.rb b/actionpack/test/controller/parameters/parameters_permit_test.rb
index 79ce7bb3a7..7cc71fe6dc 100644
--- a/actionpack/test/controller/parameters/parameters_permit_test.rb
+++ b/actionpack/test/controller/parameters/parameters_permit_test.rb
@@ -32,15 +32,39 @@ class ParametersPermitTest < ActiveSupport::TestCase
assert !@params.values_at(:person).first.permitted?
end
+ test "permitted is sticky on accessors" do
+ @params.permit!
+ assert @params.slice(:person).permitted?
+ assert @params[:person][:name].permitted?
+ assert @params[:person].except(:name).permitted?
+
+ @params.each { |key, value| assert(value.permitted?) if key == "person" }
+
+ assert @params.fetch(:person).permitted?
+
+ assert @params.values_at(:person).first.permitted?
+ end
+
test "not permitted is sticky on mutators" do
assert !@params.delete_if { |k| k == "person" }.permitted?
assert !@params.keep_if { |k,v| k == "person" }.permitted?
end
+ test "permitted is sticky on mutators" do
+ @params.permit!
+ assert @params.delete_if { |k| k == "person" }.permitted?
+ assert @params.keep_if { |k,v| k == "person" }.permitted?
+ end
+
test "not permitted is sticky beyond merges" do
assert !@params.merge(a: "b").permitted?
end
+ test "permitted is sticky beyond merges" do
+ @params.permit!
+ assert @params.merge(a: "b").permitted?
+ end
+
test "modifying the parameters" do
@params[:person][:hometown] = "Chicago"
@params[:person][:family] = { brother: "Jonas" }