Commit 2faa4bba40909778c1732894faf42a0f00e87cc4
1 parent
3a63f6f3
Exists in
master
and in
4 other branches
Update Note#upvote? to support emoji voting
Showing
2 changed files
with
11 additions
and
1 deletions
Show diff stats
app/models/note.rb
| @@ -103,7 +103,7 @@ class Note < ActiveRecord::Base | @@ -103,7 +103,7 @@ class Note < ActiveRecord::Base | ||
| 103 | # Returns true if this is an upvote note, | 103 | # Returns true if this is an upvote note, |
| 104 | # otherwise false is returned | 104 | # otherwise false is returned |
| 105 | def upvote? | 105 | def upvote? |
| 106 | - note =~ /^\+1/ ? true : false | 106 | + note.start_with?('+1') || note.start_with?(':+1:') |
| 107 | end | 107 | end |
| 108 | end | 108 | end |
| 109 | # == Schema Information | 109 | # == Schema Information |
spec/models/note_spec.rb
| @@ -35,6 +35,16 @@ describe Note do | @@ -35,6 +35,16 @@ describe Note do | ||
| 35 | note = Factory(:note, note: "-1 for this") | 35 | note = Factory(:note, note: "-1 for this") |
| 36 | note.should_not be_upvote | 36 | note.should_not be_upvote |
| 37 | end | 37 | end |
| 38 | + | ||
| 39 | + it "recognizes a +1 emoji as a vote" do | ||
| 40 | + note = build(:note, note: ":+1: for this") | ||
| 41 | + note.should be_upvote | ||
| 42 | + end | ||
| 43 | + | ||
| 44 | + it "recognizes a neutral emoji note" do | ||
| 45 | + note = build(:note, note: "I would :+1: this, but I don't want to") | ||
| 46 | + note.should_not be_upvote | ||
| 47 | + end | ||
| 38 | end | 48 | end |
| 39 | 49 | ||
| 40 | let(:project) { create(:project) } | 50 | let(:project) { create(:project) } |