summaryrefslogtreecommitdiff
path: root/app/models/note.rb
diff options
context:
space:
mode:
authorRiyad Preukschas <riyad@informatik.uni-bremen.de>2012-10-30 03:27:36 +0100
committerRiyad Preukschas <riyad@informatik.uni-bremen.de>2012-12-03 22:51:56 +0100
commitae067ee322e6702fb5ef0fd4f0cc4d4d5106cbde (patch)
tree28f76dc83a291a23488a6351bf2d2a555d884c68 /app/models/note.rb
parent6c6f415cae54be4dae4522e901ed55c9dae04a15 (diff)
downloadgitlab-ce-ae067ee322e6702fb5ef0fd4f0cc4d4d5106cbde.tar.gz
Fix vote counting
Diffstat (limited to 'app/models/note.rb')
-rw-r--r--app/models/note.rb16
1 files changed, 14 insertions, 2 deletions
diff --git a/app/models/note.rb b/app/models/note.rb
index a7bde1c5d8c..17b76615fa2 100644
--- a/app/models/note.rb
+++ b/app/models/note.rb
@@ -85,7 +85,9 @@ class Note < ActiveRecord::Base
# Returns true if this is a downvote note,
# otherwise false is returned
def downvote?
- note.start_with?('-1') || note.start_with?(':-1:')
+ votable? && (note.start_with?('-1') ||
+ note.start_with?(':-1:')
+ )
end
def for_commit?
@@ -100,6 +102,10 @@ class Note < ActiveRecord::Base
line_code.present?
end
+ def for_issue?
+ noteable_type == "Issue"
+ end
+
def for_merge_request?
noteable_type == "MergeRequest"
end
@@ -150,6 +156,12 @@ class Note < ActiveRecord::Base
# Returns true if this is an upvote note,
# otherwise false is returned
def upvote?
- note.start_with?('+1') || note.start_with?(':+1:')
+ votable? && (note.start_with?('+1') ||
+ note.start_with?(':+1:')
+ )
+ end
+
+ def votable?
+ for_issue? || (for_merge_request? && !for_diff_line?)
end
end