diff options
Diffstat (limited to 'lib/api')
-rw-r--r-- | lib/api/discussions.rb | 4 | ||||
-rw-r--r-- | lib/api/helpers/discussions_helpers.rb | 13 | ||||
-rw-r--r-- | lib/api/helpers/notes_helpers.rb | 6 | ||||
-rw-r--r-- | lib/api/notes.rb | 4 |
4 files changed, 21 insertions, 6 deletions
diff --git a/lib/api/discussions.rb b/lib/api/discussions.rb index 91eb6a23701..8afe6dda414 100644 --- a/lib/api/discussions.rb +++ b/lib/api/discussions.rb @@ -7,9 +7,7 @@ module API before { authenticate! } - NOTEABLE_TYPES = [Issue, Snippet, MergeRequest, Commit].freeze - - NOTEABLE_TYPES.each do |noteable_type| + Helpers::DiscussionsHelpers.noteable_types.each do |noteable_type| parent_type = noteable_type.parent_class.to_s.underscore noteables_str = noteable_type.to_s.underscore.pluralize noteables_path = noteable_type == Commit ? "repository/#{noteables_str}" : noteables_str diff --git a/lib/api/helpers/discussions_helpers.rb b/lib/api/helpers/discussions_helpers.rb new file mode 100644 index 00000000000..94a5bf75c39 --- /dev/null +++ b/lib/api/helpers/discussions_helpers.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +module API + module Helpers + module DiscussionsHelpers + def self.noteable_types + # This is a method instead of a constant, allowing EE to more easily + # extend it. + [Issue, Snippet, MergeRequest, Commit] + end + end + end +end diff --git a/lib/api/helpers/notes_helpers.rb b/lib/api/helpers/notes_helpers.rb index 216b2c45741..41441ac82bf 100644 --- a/lib/api/helpers/notes_helpers.rb +++ b/lib/api/helpers/notes_helpers.rb @@ -3,6 +3,12 @@ module API module Helpers module NotesHelpers + def self.noteable_types + # This is a method instead of a constant, allowing EE to more easily + # extend it. + [Issue, MergeRequest, Snippet] + end + def update_note(noteable, note_id) note = noteable.notes.find(params[:note_id]) diff --git a/lib/api/notes.rb b/lib/api/notes.rb index f7bd092ce50..416cf39d3ec 100644 --- a/lib/api/notes.rb +++ b/lib/api/notes.rb @@ -7,9 +7,7 @@ module API before { authenticate! } - NOTEABLE_TYPES = [Issue, MergeRequest, Snippet].freeze - - NOTEABLE_TYPES.each do |noteable_type| + Helpers::NotesHelpers.noteable_types.each do |noteable_type| parent_type = noteable_type.parent_class.to_s.underscore noteables_str = noteable_type.to_s.underscore.pluralize |