diff options
author | Z.J. van de Weg <zegerjan@gitlab.com> | 2016-06-03 12:44:04 +0300 |
---|---|---|
committer | Fatih Acet <acetfatih@gmail.com> | 2016-09-19 19:47:43 +0300 |
commit | 25004cbc32432d989a05532925c5c4c591cca1b5 (patch) | |
tree | 24b83bb5993f196c7fcfd0e0c30d14b4cc26dd31 /spec/controllers/snippets_controller_spec.rb | |
parent | b94de5fd555213ae28030c33c27440228f8efb65 (diff) |
Snippets get award emoji! :thumbsup:
Diffstat (limited to 'spec/controllers/snippets_controller_spec.rb')
-rw-r--r-- | spec/controllers/snippets_controller_spec.rb | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/spec/controllers/snippets_controller_spec.rb b/spec/controllers/snippets_controller_spec.rb index 2a89159c070..2ea57e50e76 100644 --- a/spec/controllers/snippets_controller_spec.rb +++ b/spec/controllers/snippets_controller_spec.rb @@ -1,9 +1,9 @@ require 'spec_helper' describe SnippetsController do - describe 'GET #show' do - let(:user) { create(:user) } + let(:user) { create(:user) } + describe 'GET #show' do context 'when the personal snippet is private' do let(:personal_snippet) { create(:personal_snippet, :private, author: user) } @@ -230,4 +230,31 @@ describe SnippetsController do end end end + + context 'award emoji on snippets' do + let(:personal_snippet) { create(:personal_snippet, :private, author: user) } + + before do + sign_in(user) + end + + describe 'POST #toggle_award_emoji' do + it "toggles the award emoji" do + expect do + post(:toggle_award_emoji, id: personal_snippet.to_param, name: "thumbsup") + end.to change { personal_snippet.award_emoji.count }.by(1) + + expect(response.status).to eq(200) + end + + it "removes the already awarded emoji" do + post(:toggle_award_emoji, id: personal_snippet.to_param, name: "thumbsup") + expect do + post(:toggle_award_emoji, id: personal_snippet.to_param, name: "thumbsup") + end.to change { personal_snippet.award_emoji.count }.by(-1) + + expect(response.status).to eq(200) + end + end + end end |