Merge pull request #5724 from Popl7/add_thumbsup_thumbsdown_emoji_voting

Thumbsup and thumbsdown emoji should be counted when voting
This commit is contained in:
Dmitriy Zaporozhets 2013-12-01 23:33:48 -08:00
commit 5fd90cd5e4
2 changed files with 14 additions and 2 deletions

View file

@ -157,7 +157,8 @@ class Note < ActiveRecord::Base
# otherwise false is returned
def downvote?
votable? && (note.start_with?('-1') ||
note.start_with?(':-1:')
note.start_with?(':-1:') ||
note.start_with?(':thumbsdown:')
)
end
@ -206,7 +207,8 @@ class Note < ActiveRecord::Base
# otherwise false is returned
def upvote?
votable? && (note.start_with?('+1') ||
note.start_with?(':+1:')
note.start_with?(':+1:') ||
note.start_with?(':thumbsup:')
)
end

View file

@ -61,6 +61,11 @@ describe Note do
note.should be_upvote
end
it "recognizes a thumbsup emoji as a vote" do
note = build(:votable_note, note: ":thumbsup: for this")
note.should be_upvote
end
it "recognizes a -1 note" do
note = create(:votable_note, note: "-1 for this")
note.should be_downvote
@ -70,6 +75,11 @@ describe Note do
note = build(:votable_note, note: ":-1: for this")
note.should be_downvote
end
it "recognizes a thumbsdown emoji as a vote" do
note = build(:votable_note, note: ":thumbsdown: for this")
note.should be_downvote
end
end
let(:project) { create(:project) }