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

Keep public permissions around in spec

Klaus Zanders1af13d044ade
diff --git a/lib/open_project/access_control.rb b/lib/open_project/access_control.rb
index 3d9ada3c900..5a10df26251 100644
--- a/lib/open_project/access_control.rb
+++ b/lib/open_project/access_control.rb
@@ -70,7 +70,7 @@ module OpenProject
permissions.detect { |p| p.controller_actions.include?(permission_path) }
else
- permissions.detect { |p| p.name == action }
+ permissions.detect { |p| p.name == action&.to_sym }
end
end
diff --git a/spec/models/activities/fetcher_integration_spec.rb b/spec/models/activities/fetcher_integration_spec.rb
index f33f9ab83f5..267ff56eda9 100644
--- a/spec/models/activities/fetcher_integration_spec.rb
+++ b/spec/models/activities/fetcher_integration_spec.rb
@@ -76,7 +76,7 @@ RSpec.describe Activities::Fetcher, 'integration' do
it 'finds only events for which permissions are satisfied' do
# project attributes, news and message only require the user to be member
expect(subject.map(&:journable_id))
- .to match_array([project.id, message.id, news.id])
+ .to contain_exactly(project.id, message.id, news.id)
end
end
@@ -98,7 +98,7 @@ RSpec.describe Activities::Fetcher, 'integration' do
it 'finds only events matching the scope' do
expect(subject.map(&:journable_id))
- .to match_array([message.id, time_entry.id])
+ .to contain_exactly(message.id, time_entry.id)
end
end
end
@@ -114,13 +114,18 @@ RSpec.describe Activities::Fetcher, 'integration' do
context 'if lacking permissions' do
before do
- role.role_permissions.destroy_all
+ role
+ .role_permissions
+ # n.b. public permissions are now stored in the database just like others, so to keep the tests like they are
+ # we need to filter them out here
+ .reject { |permission| OpenProject::AccessControl.permission(permission.permission).public? }
+ .map(&:destroy)
end
it 'finds only events for which permissions are satisfied' do
# project attributes, news and message only require the user to be member
expect(subject.map(&:journable_id))
- .to match_array([project.id, message.id, news.id])
+ .to contain_exactly(project.id, message.id, news.id)
end
end
@@ -142,7 +147,7 @@ RSpec.describe Activities::Fetcher, 'integration' do
it 'finds only events matching the scope' do
expect(subject.map(&:journable_id))
- .to match_array([message.id, time_entry.id])
+ .to contain_exactly(message.id, time_entry.id)
end
end
end
@@ -184,7 +189,7 @@ RSpec.describe Activities::Fetcher, 'integration' do
it 'lacks events from subproject' do
expect(subject.map(&:journable_id))
- .to match_array [project.id, news.id, work_package.id]
+ .to contain_exactly(project.id, news.id, work_package.id)
end
end
@@ -193,7 +198,7 @@ RSpec.describe Activities::Fetcher, 'integration' do
it 'lacks events from subproject' do
expect(subject.map(&:journable_id))
- .to match_array [project.id, news.id, work_package.id]
+ .to contain_exactly(project.id, news.id, work_package.id)
end
end
@@ -209,7 +214,7 @@ RSpec.describe Activities::Fetcher, 'integration' do
it 'finds only events for which permissions are satisfied' do
# project attributes and news only require the user to be member
expect(subject.map(&:journable_id))
- .to match_array([project.id, subproject.id, news.id, subproject_news.id, work_package.id])
+ .to contain_exactly(project.id, subproject.id, news.id, subproject_news.id, work_package.id)
expect(subject.filter { |e| e.event_type.starts_with?('work_package') }.map(&:journable_id))
.not_to include(subproject_work_package.id)
end
@@ -224,7 +229,7 @@ RSpec.describe Activities::Fetcher, 'integration' do
it 'lacks events from subproject' do
expect(subject.map(&:journable_id))
- .to match_array [project.id, news.id, work_package.id]
+ .to contain_exactly(project.id, news.id, work_package.id)
end
end
end
@@ -271,7 +276,7 @@ RSpec.describe Activities::Fetcher, 'integration' do
it 'finds only events for which permissions are satisfied' do
# project attributes, news and message only require the user to be member
expect(subject.map(&:journable_id))
- .to match_array([project.id, message.id, news.id])
+ .to contain_exactly(project.id, message.id, news.id)
end
end
@@ -282,7 +287,7 @@ RSpec.describe Activities::Fetcher, 'integration' do
it 'finds only events matching the scope' do
expect(subject.map(&:journable_id))
- .to match_array([message.id, time_entry.id])
+ .to contain_exactly(message.id, time_entry.id)
end
end
end