OpenProject is the leading open source project management software.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
openproject/spec/features/global_roles/mock_global_permissions.rb

27 lines
894 B

def mock_global_permissions(permissions)
mapped = permissions.map do |name, options|
mock_permissions(name, options.merge(global: true))
end
mapped_modules = permissions.map do |_, options|
options[:project_module] || 'Foo'
end.uniq
allow(OpenProject::AccessControl).to receive(:modules).and_wrap_original do |m, *args|
m.call(*args) + mapped_modules.map { |name| { order: 0, name: name } }
end
allow(OpenProject::AccessControl).to receive(:permissions).and_wrap_original do |m, *args|
m.call(*args) + mapped
end
allow(OpenProject::AccessControl).to receive(:global_permissions).and_wrap_original do |m, *args|
m.call(*args) + mapped
end
end
def mock_permissions(name, options = {})
::OpenProject::AccessControl::Permission.new(
name,
{ does_not: :matter },
{ project_module: 'Foo', public: false, global: false }.merge(options)
)
end