summaryrefslogtreecommitdiff
path: root/app/models/concerns/mentionable.rb
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2015-11-30 22:43:54 +0100
committerDouwe Maan <douwe@gitlab.com>2015-11-30 22:43:54 +0100
commit4a0ebccf6b96184888f2d28b6e97592c6cb239c7 (patch)
tree8fc56938b447344e3614e87b5e64ec1d13a03008 /app/models/concerns/mentionable.rb
parentbf5e7252ee5ffb5198b7916d1ad8f3436723721a (diff)
downloadgitlab-ce-4a0ebccf6b96184888f2d28b6e97592c6cb239c7.tar.gz
Fix specs
Diffstat (limited to 'app/models/concerns/mentionable.rb')
-rw-r--r--app/models/concerns/mentionable.rb11
1 files changed, 8 insertions, 3 deletions
diff --git a/app/models/concerns/mentionable.rb b/app/models/concerns/mentionable.rb
index 193c91f1742..0d6cd86aade 100644
--- a/app/models/concerns/mentionable.rb
+++ b/app/models/concerns/mentionable.rb
@@ -62,13 +62,18 @@ module Mentionable
return [] if text.blank?
refs = all_references(current_user, text, load_lazy_references: load_lazy_references)
- (refs.issues + refs.merge_requests + refs.commits) - [local_reference]
+ refs = (refs.issues + refs.merge_requests + refs.commits)
+
+ # We're using this method instead of Array diffing because that requires
+ # both of the object's `hash` values to be the same, which may not be the
+ # case for otherwise identical Commit objects.
+ refs.reject! { |ref| ref == local_reference }
end
# Create a cross-reference Note for each GFM reference to another Mentionable found in +mentionable_text+.
def create_cross_references!(author = self.author, without = [], text = self.mentionable_text)
refs = referenced_mentionables(author, text)
-
+
# We're using this method instead of Array diffing because that requires
# both of the object's `hash` values to be the same, which may not be the
# case for otherwise identical Commit objects.
@@ -111,7 +116,7 @@ module Mentionable
# Only include changed fields that are mentionable
source.select { |key, val| mentionable.include?(key) }
end
-
+
# Determine whether or not a cross-reference Note has already been created between this Mentionable and
# the specified target.
def cross_reference_exists?(target)