mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Compact array of values added to PermissionSet instance
This commit is contained in:
parent
e638c613d0
commit
00ff0a6776
2 changed files with 7 additions and 1 deletions
|
@ -5,7 +5,7 @@ module ActiveModel
|
||||||
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)
|
||||||
|
|
|
@ -13,6 +13,12 @@ class PermissionSetTest < ActiveModel::TestCase
|
||||||
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' ]
|
||||||
|
|
Loading…
Reference in a new issue