Permalink
Browse files

inherit global trust for all nested hashes

  • Loading branch information...
1 parent 008219e commit 3dfeab11ef2efc67a6d1facea5010dd440a50902 @ryanb committed Jun 1, 2009
Showing with 8 additions and 0 deletions.
  1. +1 −0 lib/trusted_params/hash_additions.rb
  2. +7 −0 spec/trusted_params/hash_additions_spec.rb
@@ -3,6 +3,7 @@ module HashAdditions
def trust(*attribute_names)
if attribute_names.empty?
@trusted_attributes = :all
+ each_key { |k| self[k].trust if self[k].kind_of? Hash }
else
@trusted_attributes = attribute_names.map(&:to_sym)
attribute_names.each do |attribute_name|
@@ -51,4 +51,11 @@
h2 = h1.dup
h2.should be_trusted(:foo)
end
+
+ it "should inherit trust in all nested hashes" do
+ @hash[:child] = { :boing => "bong" }
+ @hash.trust
+ @hash.should be_trusted(:child)
+ @hash[:child].should be_trusted(:boing)
+ end
end

0 comments on commit 3dfeab1

Please sign in to comment.