summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-12-01 23:33:48 -0800
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-12-01 23:33:48 -0800
commit5fd90cd5e4a038e4b0ad9e8893eec7155e0b6cb5 (patch)
treee2c00465f06eeec2b15fca1bb9753f4690e1c77a
parentdc29b237330a0a4277ebcb339a7b65296404267c (diff)
parent64efc05229b04d9928d621572d01bb1952ac0f65 (diff)
downloadgitlab-ce-5fd90cd5e4a038e4b0ad9e8893eec7155e0b6cb5.tar.gz
Merge pull request #5724 from Popl7/add_thumbsup_thumbsdown_emoji_voting
Thumbsup and thumbsdown emoji should be counted when voting
-rw-r--r--app/models/note.rb6
-rw-r--r--spec/models/note_spec.rb10
2 files changed, 14 insertions, 2 deletions
diff --git a/app/models/note.rb b/app/models/note.rb
index 7e7387abed6..8284da8616f 100644
--- a/app/models/note.rb
+++ b/app/models/note.rb
@@ -157,7 +157,8 @@ class Note < ActiveRecord::Base
# otherwise false is returned
def downvote?
votable? && (note.start_with?('-1') ||
- note.start_with?(':-1:')
+ note.start_with?(':-1:') ||
+ note.start_with?(':thumbsdown:')
)
end
@@ -206,7 +207,8 @@ class Note < ActiveRecord::Base
# otherwise false is returned
def upvote?
votable? && (note.start_with?('+1') ||
- note.start_with?(':+1:')
+ note.start_with?(':+1:') ||
+ note.start_with?(':thumbsup:')
)
end
diff --git a/spec/models/note_spec.rb b/spec/models/note_spec.rb
index 42c405d8e50..55b264ce8cf 100644
--- a/spec/models/note_spec.rb
+++ b/spec/models/note_spec.rb
@@ -61,6 +61,11 @@ describe Note do
note.should be_upvote
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
note = create(:votable_note, note: "-1 for this")
note.should be_downvote
@@ -70,6 +75,11 @@ describe Note do
note = build(:votable_note, note: ":-1: for this")
note.should be_downvote
end
+
+ it "recognizes a thumbsdown emoji as a vote" do
+ note = build(:votable_note, note: ":thumbsdown: for this")
+ note.should be_downvote
+ end
end
let(:project) { create(:project) }