Commit 05f5212d authored by Eugenia Grieff's avatar Eugenia Grieff

Include read_group_timelogs policy in projects

parent c895dc26
......@@ -95,6 +95,10 @@ module EE
!@subject.design_management_enabled?
end
condition(:group_timelogs_available) do
@subject.feature_available?(:group_timelogs)
end
rule { admin }.enable :change_repository_storage
rule { support_bot }.enable :guest_access
......@@ -120,6 +124,8 @@ module EE
prevent :admin_issue_link
end
rule { ~group_timelogs_available }.prevent :read_group_timelogs
rule { can?(:read_issue) }.policy do
enable :read_issue_link
enable :read_design
......@@ -131,6 +137,7 @@ module EE
enable :admin_issue_link
enable :admin_epic_issue
enable :read_package
enable :read_group_timelogs
end
rule { can?(:developer_access) }.policy do
......
# frozen_string_literal: true
class TimelogPolicy < BasePolicy
delegate { @subject.issuable.resource_parent.group }
delegate { @subject.issuable.resource_parent }
end
......@@ -1102,4 +1102,62 @@ describe ProjectPolicy do
it { is_expected.to be_allowed(:read_reject_unsigned_commits) }
end
end
context 'when timelogs report feature is enabled' do
before do
stub_licensed_features(group_timelogs: true)
end
context 'admin' do
let(:current_user) { admin }
it { is_expected.to be_allowed(:read_group_timelogs) }
end
context 'with owner' do
let(:current_user) { owner }
it { is_expected.to be_allowed(:read_group_timelogs) }
end
context 'with maintainer' do
let(:current_user) { maintainer }
it { is_expected.to be_allowed(:read_group_timelogs) }
end
context 'with reporter' do
let(:current_user) { reporter }
it { is_expected.to be_allowed(:read_group_timelogs) }
end
context 'with guest' do
let(:current_user) { guest }
it { is_expected.to be_disallowed(:read_group_timelogs) }
end
context 'with non member' do
let(:current_user) { create(:user) }
it { is_expected.to be_disallowed(:read_group_timelogs) }
end
context 'with anonymous' do
let(:current_user) { nil }
it { is_expected.to be_disallowed(:read_group_timelogs) }
end
end
context 'when timelogs report feature is disabled' do
let(:current_user) { admin }
before do
stub_licensed_features(group_timelogs: false)
end
it { is_expected.to be_disallowed(:read_group_timelogs) }
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment