Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Cleanup specs for UserAllowedService

Klaus Zanders3aab4ea5b634
diff --git a/spec/services/authorization/user_allowed_service_spec.rb b/spec/services/authorization/user_allowed_service_spec.rb
index cc7e745fef1..27246eae5fb 100644
--- a/spec/services/authorization/user_allowed_service_spec.rb
+++ b/spec/services/authorization/user_allowed_service_spec.rb
@@ -62,21 +62,11 @@ RSpec.describe Authorization::UserAllowedService do
Array(context).each do |project|
project.active = true
- allow(project)
- .to receive(:allows_to?)
- .with(action)
- .and_return(project_allows_to)
-
- allow(Authorization)
- .to receive(:roles)
- .with(user, project)
- .and_return(user_roles_in_project)
+ allow(project).to receive(:allows_to?).with(action).and_return(project_allows_to)
+ allow(Authorization).to receive(:roles).with(user, project).and_return(user_roles_in_project)
end
- allow(role)
- .to receive(:allowed_to?)
- .with(action)
- .and_return(role_grants_action)
+ allow(role).to receive(:allowed_to?).with(action).and_return(role_grants_action)
end
context 'with the user having a granting role' do
@@ -86,10 +76,7 @@ RSpec.describe Authorization::UserAllowedService do
it 'does not call the db twice for a project' do
Array(context).each do |project|
- allow(Authorization)
- .to receive(:roles)
- .with(user, project)
- .and_return(user_roles_in_project)
+ allow(Authorization).to receive(:roles).with(user, project).and_return(user_roles_in_project)
end
subject
@@ -277,15 +264,8 @@ RSpec.describe Authorization::UserAllowedService do
context 'with the user having a granting role' do
before do
- allow(Authorization)
- .to receive(:roles)
- .with(user, nil)
- .and_return(user_roles_in_project)
-
- allow(role)
- .to receive(:allowed_to?)
- .with(action)
- .and_return(true)
+ allow(Authorization).to receive(:roles).with(user, nil).and_return(user_roles_in_project)
+ allow(role).to receive(:allowed_to?).with(action).and_return(true)
end
context 'but the user not being active' do
@@ -305,15 +285,8 @@ RSpec.describe Authorization::UserAllowedService do
context 'with the user not having a granting role' do
before do
- allow(Authorization)
- .to receive(:roles)
- .with(user, nil)
- .and_return(user_roles_in_project)
-
- allow(role)
- .to receive(:allowed_to?)
- .with(action)
- .and_return(false)
+ allow(Authorization).to receive(:roles).with(user, nil).and_return(user_roles_in_project)
+ allow(role).to receive(:allowed_to?).with(action).and_return(false)
end
it 'is false' do