Commit 5fd90cd5e4a038e4b0ad9e8893eec7155e0b6cb5
Exists in
master
and in
4 other branches
Merge pull request #5724 from Popl7/add_thumbsup_thumbsdown_emoji_voting
Thumbsup and thumbsdown emoji should be counted when voting
Showing
2 changed files
with
14 additions
and
2 deletions
Show diff stats
app/models/note.rb
@@ -157,7 +157,8 @@ class Note < ActiveRecord::Base | @@ -157,7 +157,8 @@ class Note < ActiveRecord::Base | ||
157 | # otherwise false is returned | 157 | # otherwise false is returned |
158 | def downvote? | 158 | def downvote? |
159 | votable? && (note.start_with?('-1') || | 159 | votable? && (note.start_with?('-1') || |
160 | - note.start_with?(':-1:') | 160 | + note.start_with?(':-1:') || |
161 | + note.start_with?(':thumbsdown:') | ||
161 | ) | 162 | ) |
162 | end | 163 | end |
163 | 164 | ||
@@ -206,7 +207,8 @@ class Note < ActiveRecord::Base | @@ -206,7 +207,8 @@ class Note < ActiveRecord::Base | ||
206 | # otherwise false is returned | 207 | # otherwise false is returned |
207 | def upvote? | 208 | def upvote? |
208 | votable? && (note.start_with?('+1') || | 209 | votable? && (note.start_with?('+1') || |
209 | - note.start_with?(':+1:') | 210 | + note.start_with?(':+1:') || |
211 | + note.start_with?(':thumbsup:') | ||
210 | ) | 212 | ) |
211 | end | 213 | end |
212 | 214 |
spec/models/note_spec.rb
@@ -61,6 +61,11 @@ describe Note do | @@ -61,6 +61,11 @@ describe Note do | ||
61 | note.should be_upvote | 61 | note.should be_upvote |
62 | end | 62 | end |
63 | 63 | ||
64 | + it "recognizes a thumbsup emoji as a vote" do | ||
65 | + note = build(:votable_note, note: ":thumbsup: for this") | ||
66 | + note.should be_upvote | ||
67 | + end | ||
68 | + | ||
64 | it "recognizes a -1 note" do | 69 | it "recognizes a -1 note" do |
65 | note = create(:votable_note, note: "-1 for this") | 70 | note = create(:votable_note, note: "-1 for this") |
66 | note.should be_downvote | 71 | note.should be_downvote |
@@ -70,6 +75,11 @@ describe Note do | @@ -70,6 +75,11 @@ describe Note do | ||
70 | note = build(:votable_note, note: ":-1: for this") | 75 | note = build(:votable_note, note: ":-1: for this") |
71 | note.should be_downvote | 76 | note.should be_downvote |
72 | end | 77 | end |
78 | + | ||
79 | + it "recognizes a thumbsdown emoji as a vote" do | ||
80 | + note = build(:votable_note, note: ":thumbsdown: for this") | ||
81 | + note.should be_downvote | ||
82 | + end | ||
73 | end | 83 | end |
74 | 84 | ||
75 | let(:project) { create(:project) } | 85 | let(:project) { create(:project) } |