diff options
| author | Yorick Peterse <yorickpeterse@gmail.com> | 2019-02-21 14:34:40 +0100 |
|---|---|---|
| committer | Yorick Peterse <yorickpeterse@gmail.com> | 2019-03-04 17:44:56 +0100 |
| commit | 654c4dd9224dc941c073b44730a6461e5d06edfc (patch) | |
| tree | 130deb16c0f6a767ba51448767e0d1a5244ef9e2 /lib/api/helpers | |
| parent | c01e93249da72cf91f3516da6bb48d8989335508 (diff) | |
| download | gitlab-ce-654c4dd9224dc941c073b44730a6461e5d06edfc.tar.gz | |
Refactor API noteable types constants
This replaces API::Notes::NOTEABLE_TYPES and
API::Discussions::NOTEABLE_TYPES with class methods defined in a
separate helper modules. This allows EE to extend the list of noteable
types, without having to modify the constant in-place. We can't define
these methods directly in the API classes, as they would be used before
we're able to extend them in EE.
Diffstat (limited to 'lib/api/helpers')
| -rw-r--r-- | lib/api/helpers/discussions_helpers.rb | 13 | ||||
| -rw-r--r-- | lib/api/helpers/notes_helpers.rb | 6 |
2 files changed, 19 insertions, 0 deletions
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]) |
