Permalink
Browse files

Compact array of values added to PermissionSet instance

  • Loading branch information...
1 parent e638c61 commit 00ff0a6776aca4977dc6eab5ec130c67e36c36ac @pomnikita pomnikita committed Jun 7, 2012
@@ -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)
@@ -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 00ff0a6

Please sign in to comment.