Skip to content

Commit

Permalink
Compact array of values added to PermissionSet instance
Browse files Browse the repository at this point in the history
  • Loading branch information
pomnikita committed Jun 7, 2012
1 parent e638c61 commit 00ff0a6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Expand Up @@ -5,7 +5,7 @@ module MassAssignmentSecurity
class PermissionSet < Set class PermissionSet < Set


def +(values) def +(values)
super(values.map(&:to_s)) super(values.compact.map(&:to_s))
end end


def include?(key) def include?(key)
Expand Down
Expand Up @@ -13,6 +13,12 @@ def setup
assert new_list.include?('admin'), "did not add collection to #{@permission_list.inspect}}" assert new_list.include?('admin'), "did not add collection to #{@permission_list.inspect}}"
end 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 test "include? normalizes multi-parameter keys" do
multi_param_key = 'admin(1)' multi_param_key = 'admin(1)'
new_list = @permission_list += [ 'admin' ] new_list = @permission_list += [ 'admin' ]
Expand Down

0 comments on commit 00ff0a6

Please sign in to comment.