diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-20 17:34:42 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-20 17:34:42 +0300 |
commit | 9f46488805e86b1bc341ea1620b866016c2ce5ed (patch) | |
tree | f9748c7e287041e37d6da49e0a29c9511dc34768 /app/models/event.rb | |
parent | dfc92d081ea0332d69c8aca2f0e745cb48ae5e6d (diff) |
Add latest changes from gitlab-org/gitlab@13-0-stable-ee
Diffstat (limited to 'app/models/event.rb')
-rw-r--r-- | app/models/event.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/app/models/event.rb b/app/models/event.rb index 447ab753421..12b85697690 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -96,6 +96,8 @@ class Event < ApplicationRecord end scope :for_milestone_id, ->(milestone_id) { where(target_type: "Milestone", target_id: milestone_id) } + scope :for_wiki_meta, ->(meta) { where(target_type: 'WikiPage::Meta', target_id: meta.id) } + scope :created_at, ->(time) { where(created_at: time) } # Authors are required as they're used to display who pushed data. # @@ -313,6 +315,10 @@ class Event < ApplicationRecord note? && target && target.for_personal_snippet? end + def design_note? + note? && note.for_design? + end + def note_target target.noteable end @@ -380,6 +386,11 @@ class Event < ApplicationRecord protected + # rubocop:disable Metrics/CyclomaticComplexity + # rubocop:disable Metrics/PerceivedComplexity + # + # TODO Refactor this method so we no longer need to disable the above cops + # https://gitlab.com/gitlab-org/gitlab/-/issues/216879. def capability @capability ||= begin if push_action? || commit_note? @@ -396,9 +407,13 @@ class Event < ApplicationRecord :read_milestone elsif wiki_page? :read_wiki + elsif design_note? + :read_design end end end + # rubocop:enable Metrics/CyclomaticComplexity + # rubocop:enable Metrics/PerceivedComplexity private |