BigW Consortium Gitlab

Commit 2faa4bba by Robert Speicher

Update Note#upvote? to support emoji voting

parent 3a63f6f3
...@@ -103,7 +103,7 @@ class Note < ActiveRecord::Base ...@@ -103,7 +103,7 @@ class Note < ActiveRecord::Base
# Returns true if this is an upvote note, # Returns true if this is an upvote note,
# otherwise false is returned # otherwise false is returned
def upvote? def upvote?
note =~ /^\+1/ ? true : false note.start_with?('+1') || note.start_with?(':+1:')
end end
end end
# == Schema Information # == Schema Information
......
...@@ -35,6 +35,16 @@ describe Note do ...@@ -35,6 +35,16 @@ describe Note do
note = Factory(:note, note: "-1 for this") note = Factory(:note, note: "-1 for this")
note.should_not be_upvote note.should_not be_upvote
end end
it "recognizes a +1 emoji as a vote" do
note = build(:note, note: ":+1: for this")
note.should be_upvote
end
it "recognizes a neutral emoji note" do
note = build(:note, note: "I would :+1: this, but I don't want to")
note.should_not be_upvote
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