aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel
diff options
context:
space:
mode:
authorPiotr Sarnacki <drogus@gmail.com>2012-06-08 11:35:13 -0700
committerPiotr Sarnacki <drogus@gmail.com>2012-06-08 11:35:13 -0700
commit41d63710f22065c16582125873a4e3c14357bd7f (patch)
tree92cd96eaa972b4abb02501398e6245f1060b6b0f /activemodel
parentd1136e6ad0aab44cfc0626c553b3ee82479f6196 (diff)
parent00ff0a6776aca4977dc6eab5ec130c67e36c36ac (diff)
downloadrails-41d63710f22065c16582125873a4e3c14357bd7f.tar.gz
rails-41d63710f22065c16582125873a4e3c14357bd7f.tar.bz2
rails-41d63710f22065c16582125873a4e3c14357bd7f.zip
Merge pull request #6668 from pomnikita/master
Compact array of values added to PermissionSet instance
Diffstat (limited to 'activemodel')
-rw-r--r--activemodel/lib/active_model/mass_assignment_security/permission_set.rb2
-rw-r--r--activemodel/test/cases/mass_assignment_security/permission_set_test.rb6
2 files changed, 7 insertions, 1 deletions
diff --git a/activemodel/lib/active_model/mass_assignment_security/permission_set.rb b/activemodel/lib/active_model/mass_assignment_security/permission_set.rb
index 9661349503..415ab0ad17 100644
--- a/activemodel/lib/active_model/mass_assignment_security/permission_set.rb
+++ b/activemodel/lib/active_model/mass_assignment_security/permission_set.rb
@@ -5,7 +5,7 @@ module ActiveModel
class PermissionSet < Set
def +(values)
- super(values.map(&:to_s))
+ super(values.compact.map(&:to_s))
end
def include?(key)
diff --git a/activemodel/test/cases/mass_assignment_security/permission_set_test.rb b/activemodel/test/cases/mass_assignment_security/permission_set_test.rb
index d005b638e4..8082c49852 100644
--- a/activemodel/test/cases/mass_assignment_security/permission_set_test.rb
+++ b/activemodel/test/cases/mass_assignment_security/permission_set_test.rb
@@ -13,6 +13,12 @@ class PermissionSetTest < ActiveModel::TestCase
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' ]