Permalink
Browse files

Merge pull request #6668 from pomnikita/master

Compact array of values added to PermissionSet instance
  • Loading branch information...
2 parents d1136e6 + 00ff0a6 commit 41d63710f22065c16582125873a4e3c14357bd7f @drogus drogus committed Jun 8, 2012
View
2 activemodel/lib/active_model/mass_assignment_security/permission_set.rb
@@ -5,7 +5,7 @@ module MassAssignmentSecurity
class PermissionSet < Set
def +(values)
- super(values.map(&:to_s))
+ super(values.compact.map(&:to_s))
end
def include?(key)
View
6 activemodel/test/cases/mass_assignment_security/permission_set_test.rb
@@ -13,6 +13,12 @@ def setup
assert new_list.include?('admin'), "did not add collection to #{@permission_list.inspect}}"
end
+ test "+ compacts added collection values" do
+ added_collection = [ nil ]
+ new_list = @permission_list + added_collection
+ assert_equal new_list, @permission_list, "did not add collection to #{@permission_list.inspect}}"
+ end
+
test "include? normalizes multi-parameter keys" do
multi_param_key = 'admin(1)'
new_list = @permission_list += [ 'admin' ]

0 comments on commit 41d6371

Please sign in to comment.