Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouwe Maan <douwe@selenight.nl>2017-04-06 18:05:57 +0300
committerDouwe Maan <douwe@selenight.nl>2017-04-06 18:51:45 +0300
commitcc656a11992483911cefe035d579096581cfde57 (patch)
tree5af4a41d9ae36b3900fdfa0b312b125995c8818c /app/models/concerns/resolvable_note.rb
parent64c1735c22871d94e0bda8b9f5aece2a29739236 (diff)
Refactor resolvability checks based on type
Diffstat (limited to 'app/models/concerns/resolvable_note.rb')
-rw-r--r--app/models/concerns/resolvable_note.rb12
1 files changed, 7 insertions, 5 deletions
diff --git a/app/models/concerns/resolvable_note.rb b/app/models/concerns/resolvable_note.rb
index 2c70678429a..05eb6f86704 100644
--- a/app/models/concerns/resolvable_note.rb
+++ b/app/models/concerns/resolvable_note.rb
@@ -1,6 +1,7 @@
module ResolvableNote
extend ActiveSupport::Concern
+ # Names of all subclasses of `Note` that can be resolvable.
RESOLVABLE_TYPES = %w(DiffNote DiscussionNote).freeze
included do
@@ -8,10 +9,8 @@ module ResolvableNote
validates :resolved_by, presence: true, if: :resolved?
- # Keep this scope in sync with the logic in `#potentially_resolvable?` in subclasses of `Discussion` that are resolvable.
- # `RESOLVABLE_TYPES` should include names of all subclasses that are resolvable (where the method can return true), and
- # the scope should also match the criteria `ResolvableDiscussion#potentially_resolvable?` puts on resolvability.
- scope :potentially_resolvable, -> { where(type: RESOLVABLE_TYPES).where(noteable_type: 'MergeRequest') }
+ # Keep this scope in sync with `#potentially_resolvable?`
+ scope :potentially_resolvable, -> { where(type: RESOLVABLE_TYPES).where(noteable_type: Noteable::RESOLVABLE_TYPES) }
# Keep this scope in sync with `#resolvable?`
scope :resolvable, -> { potentially_resolvable.user }
@@ -31,7 +30,10 @@ module ResolvableNote
end
end
- delegate :potentially_resolvable?, to: :to_discussion
+ # Keep this method in sync with the `potentially_resolvable` scope
+ def potentially_resolvable?
+ RESOLVABLE_TYPES.include?(self.class.name) && noteable.supports_resolvable_notes?
+ end
# Keep this method in sync with the `resolvable` scope
def resolvable?