This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Added ActionController::Parameters#dup to retain permit state.

  • Loading branch information...
1 parent 2059b33 commit 5199f8464fba92663737b469bc5fc21106fa9f25 @Flink Flink committed Mar 28, 2012
Showing with 9 additions and 0 deletions.
  1. +4 −0 lib/action_controller/parameters.rb
  2. +5 −0 test/parameters_taint_test.rb
@@ -72,6 +72,10 @@ def slice(*keys)
self.class.new(super)
end
+ def dup
+ Marshal.load Marshal.dump self
+ end
+
private
def convert_hashes_to_parameters(key, value)
if value.is_a?(Parameters) || !value.is_a?(Hash)
@@ -53,4 +53,9 @@ class ParametersTaintTest < ActiveSupport::TestCase
test "permitting parameters that are not there should not include the keys" do
assert !@params.permit(:person, :funky).has_key?(:funky)
end
+
+ test "permit state is kept on a dup" do
+ @params.permit!
+ assert_equal @params.permitted?, @params.dup.permitted?
+ end
end

0 comments on commit 5199f84

Please sign in to comment.