Commit 64efc052 authored by vagrant's avatar vagrant

added thumbsup and thumsdown emoji voting with rspec tests

parent 2e07865f
...@@ -157,7 +157,8 @@ class Note < ActiveRecord::Base ...@@ -157,7 +157,8 @@ class Note < ActiveRecord::Base
# otherwise false is returned # otherwise false is returned
def downvote? def downvote?
votable? && (note.start_with?('-1') || votable? && (note.start_with?('-1') ||
note.start_with?(':-1:') note.start_with?(':-1:') ||
note.start_with?(':thumbsdown:')
) )
end end
...@@ -206,7 +207,8 @@ class Note < ActiveRecord::Base ...@@ -206,7 +207,8 @@ class Note < ActiveRecord::Base
# otherwise false is returned # otherwise false is returned
def upvote? def upvote?
votable? && (note.start_with?('+1') || votable? && (note.start_with?('+1') ||
note.start_with?(':+1:') note.start_with?(':+1:') ||
note.start_with?(':thumbsup:')
) )
end end
......
...@@ -61,6 +61,11 @@ describe Note do ...@@ -61,6 +61,11 @@ describe Note do
note.should be_upvote note.should be_upvote
end 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 it "recognizes a -1 note" do
note = create(:votable_note, note: "-1 for this") note = create(:votable_note, note: "-1 for this")
note.should be_downvote note.should be_downvote
...@@ -70,6 +75,11 @@ describe Note do ...@@ -70,6 +75,11 @@ describe Note do
note = build(:votable_note, note: ":-1: for this") note = build(:votable_note, note: ":-1: for this")
note.should be_downvote note.should be_downvote
end end
it "recognizes a thumbsdown emoji as a vote" do
note = build(:votable_note, note: ":thumbsdown: for this")
note.should be_downvote
end
end end
let(:project) { create(:project) } let(:project) { create(:project) }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment