diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-12-28 00:09:38 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-12-28 00:09:38 +0300 |
commit | 49c0e687c1cebabb117519a6a34ffc02a39261b0 (patch) | |
tree | fc4446dae3a53e67fc99a969fa00086bd93ba0a8 /app/policies | |
parent | 84f003a4cbf0d57afdaae8cc4f28af549b34ff33 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/policies')
-rw-r--r-- | app/policies/resource_event_policy.rb | 5 | ||||
-rw-r--r-- | app/policies/resource_label_event_policy.rb | 4 | ||||
-rw-r--r-- | app/policies/resource_milestone_event_policy.rb | 14 | ||||
-rw-r--r-- | app/policies/resource_state_event_policy.rb | 10 |
4 files changed, 31 insertions, 2 deletions
diff --git a/app/policies/resource_event_policy.rb b/app/policies/resource_event_policy.rb new file mode 100644 index 00000000000..d8142212927 --- /dev/null +++ b/app/policies/resource_event_policy.rb @@ -0,0 +1,5 @@ +# frozen_string_literal: true + +class ResourceEventPolicy < BasePolicy + condition(:can_read_issuable) { can?(:"read_#{@subject.issuable.to_ability_name}", @subject.issuable) } +end diff --git a/app/policies/resource_label_event_policy.rb b/app/policies/resource_label_event_policy.rb index de4748d9890..d9c2eed72e7 100644 --- a/app/policies/resource_label_event_policy.rb +++ b/app/policies/resource_label_event_policy.rb @@ -1,8 +1,7 @@ # frozen_string_literal: true -class ResourceLabelEventPolicy < BasePolicy +class ResourceLabelEventPolicy < ResourceEventPolicy condition(:can_read_label) { @subject.label_id.nil? || can?(:read_label, @subject.label) } - condition(:can_read_issuable) { can?(:"read_#{@subject.issuable.to_ability_name}", @subject.issuable) } rule { can_read_label }.policy do enable :read_label @@ -10,5 +9,6 @@ class ResourceLabelEventPolicy < BasePolicy rule { can_read_label & can_read_issuable }.policy do enable :read_resource_label_event + enable :read_note end end diff --git a/app/policies/resource_milestone_event_policy.rb b/app/policies/resource_milestone_event_policy.rb new file mode 100644 index 00000000000..10a1f86fb85 --- /dev/null +++ b/app/policies/resource_milestone_event_policy.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +class ResourceMilestoneEventPolicy < ResourceEventPolicy + condition(:can_read_milestone) { @subject.milestone_id.nil? || can?(:read_milestone, @subject.milestone) } + + rule { can_read_milestone }.policy do + enable :read_milestone + end + + rule { can_read_milestone & can_read_issuable }.policy do + enable :read_resource_milestone_event + enable :read_note + end +end diff --git a/app/policies/resource_state_event_policy.rb b/app/policies/resource_state_event_policy.rb new file mode 100644 index 00000000000..34df2e96eb8 --- /dev/null +++ b/app/policies/resource_state_event_policy.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +class ResourceStateEventPolicy < ResourceEventPolicy + condition(:can_read_issuable) { can?(:"read_#{@subject.issuable.to_ability_name}", @subject.issuable) } + + rule { can_read_issuable }.policy do + enable :read_resource_state_event + enable :read_note + end +end |