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

nil param value that expects a hash should return :key => nil #20

Closed
wants to merge 4 commits into
from
View
@@ -1,27 +1,27 @@
PATH
remote: .
specs:
- strong_parameters (0.1.2)
+ strong_parameters (0.1.3)
actionpack (>= 3.2.0)
activemodel (>= 3.2.0)
GEM
remote: http://rubygems.org/
specs:
- actionpack (3.2.2)
- activemodel (= 3.2.2)
- activesupport (= 3.2.2)
+ actionpack (3.2.3)
+ activemodel (= 3.2.3)
+ activesupport (= 3.2.3)
builder (~> 3.0.0)
erubis (~> 2.7.0)
journey (~> 1.0.1)
rack (~> 1.4.0)
- rack-cache (~> 1.1)
+ rack-cache (~> 1.2)
rack-test (~> 0.6.1)
sprockets (~> 2.1.2)
- activemodel (3.2.2)
- activesupport (= 3.2.2)
+ activemodel (3.2.3)
+ activesupport (= 3.2.3)
builder (~> 3.0.0)
- activesupport (3.2.2)
+ activesupport (3.2.3)
@carlosantoniodasilva

carlosantoniodasilva Feb 1, 2013

Owner

There's no need to change the lock file, please revert this.

i18n (~> 0.6)
multi_json (~> 1.0)
builder (3.0.0)
@@ -41,8 +41,6 @@ def permit(*filters)
params[filter] = self[filter] if has_key?(filter)
when Hash then
self.slice(*filter.keys).each do |key, value|
- return unless value
-
key = key.to_sym
params[key] = each_element(value) do |value|
@@ -77,4 +77,12 @@ class NestedParametersTest < ActiveSupport::TestCase
permitted = params.permit book: { genre: :type }
assert_nil permitted[:book][:genre]
end
+
+ test "nil param value that should be a hash" do
+ params = ActionController::Parameters.new({
+ :book => nil
+ })
+ permitted = params.permit :book => { :genre => :type}
@carlosantoniodasilva

carlosantoniodasilva Feb 1, 2013

Owner

Missing space before }.

+ assert_nil permitted[:book]
@carlosantoniodasilva

carlosantoniodasilva Feb 1, 2013

Owner

I think you should also assert that the key is there, right?

+ end
end