2010-01-29 20:02:12 -05:00
|
|
|
require "cases/helper"
|
|
|
|
|
2010-07-08 12:16:36 -04:00
|
|
|
class PermissionSetTest < ActiveModel::TestCase
|
2010-01-29 20:02:12 -05:00
|
|
|
|
|
|
|
def setup
|
2010-07-08 12:16:36 -04:00
|
|
|
@permission_list = ActiveModel::MassAssignmentSecurity::PermissionSet.new
|
2010-01-29 20:02:12 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
test "+ stringifies added collection values" do
|
|
|
|
symbol_collection = [ :admin ]
|
2010-07-07 11:05:42 -04:00
|
|
|
new_list = @permission_list += symbol_collection
|
2010-01-29 20:02:12 -05:00
|
|
|
|
2010-07-07 11:05:42 -04:00
|
|
|
assert new_list.include?('admin'), "did not add collection to #{@permission_list.inspect}}"
|
2010-01-29 20:02:12 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
test "include? normalizes multi-parameter keys" do
|
|
|
|
multi_param_key = 'admin(1)'
|
2010-07-07 11:05:42 -04:00
|
|
|
new_list = @permission_list += [ 'admin' ]
|
2010-01-29 20:02:12 -05:00
|
|
|
|
2010-07-07 11:05:42 -04:00
|
|
|
assert new_list.include?(multi_param_key), "#{multi_param_key} not found in #{@permission_list.inspect}"
|
2010-01-29 20:02:12 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
test "include? normal keys" do
|
|
|
|
normal_key = 'admin'
|
2010-07-07 11:05:42 -04:00
|
|
|
new_list = @permission_list += [ normal_key ]
|
2010-01-29 20:02:12 -05:00
|
|
|
|
2010-07-07 11:05:42 -04:00
|
|
|
assert new_list.include?(normal_key), "#{normal_key} not found in #{@permission_list.inspect}"
|
2010-01-29 20:02:12 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|