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-03-17 22:25:52 +0300
committerLuke "Jared" Bennett <lbennett@gitlab.com>2017-04-05 19:44:14 +0300
commit79889a6aa3dc878d196d0f2f445ab6b10ef10c74 (patch)
tree25367a69b4a529335e106d0d65c2d9a38e97f092 /app/models/concerns/resolvable_note.rb
parent80b2e18fb62b8da7410f90b3e5340b9e63e765a3 (diff)
Add specs
Diffstat (limited to 'app/models/concerns/resolvable_note.rb')
-rw-r--r--app/models/concerns/resolvable_note.rb15
1 files changed, 11 insertions, 4 deletions
diff --git a/app/models/concerns/resolvable_note.rb b/app/models/concerns/resolvable_note.rb
index eecb77ebf80..2aba979938b 100644
--- a/app/models/concerns/resolvable_note.rb
+++ b/app/models/concerns/resolvable_note.rb
@@ -1,13 +1,18 @@
module ResolvableNote
extend ActiveSupport::Concern
+ RESOLVABLE_TYPES = %w(DiffNote DiscussionNote).freeze
+
included do
belongs_to :resolved_by, class_name: "User"
validates :resolved_by, presence: true, if: :resolved?
- # Keep this scope in sync with the logic in `#resolvable?` in `Note` subclasses that are resolvable
- scope :resolvable, -> { where(type: %w(DiffNote DiscussionNote)).user.where(noteable_type: 'MergeRequest') }
+ # Keep this scope in sync with the logic in `#potentially_resolvable?` in `Discussion` subclasses that are resolvable
+ scope :potentially_resolvable, -> { where(type: RESOLVABLE_TYPES).where(noteable_type: 'MergeRequest') }
+ # Keep this scope in sync with `#resolvable?`
+ scope :resolvable, -> { potentially_resolvable.user }
+
scope :resolved, -> { resolvable.where.not(resolved_at: nil) }
scope :unresolved, -> { resolvable.where(resolved_at: nil) }
end
@@ -24,9 +29,11 @@ module ResolvableNote
end
end
- # If you update this method remember to also update the scope `resolvable`
+ delegate :potentially_resolvable?, to: :to_discussion
+
+ # Keep this method in sync with the `resolvable` scope
def resolvable?
- to_discussion.potentially_resolvable? && !system?
+ potentially_resolvable? && !system?
end
def resolved?