Commit 2faa4bba40909778c1732894faf42a0f00e87cc4

Authored by Robert Speicher
1 parent 3a63f6f3

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 103 # Returns true if this is an upvote note,
104 104 # otherwise false is returned
105 105 def upvote?
106   - note =~ /^\+1/ ? true : false
  106 + note.start_with?('+1') || note.start_with?(':+1:')
107 107 end
108 108 end
109 109 # == Schema Information
... ...
spec/models/note_spec.rb
... ... @@ -35,6 +35,16 @@ describe Note do
35 35 note = Factory(:note, note: "-1 for this")
36 36 note.should_not be_upvote
37 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 48 end
39 49  
40 50 let(:project) { create(:project) }
... ...