Fix vote counting

This commit is contained in:
Riyad Preukschas 2012-10-30 03:27:36 +01:00
parent 6c6f415cae
commit ae067ee322
7 changed files with 186 additions and 117 deletions

View file

@ -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