diff options
author | Rémy Coutable <remy@rymai.me> | 2016-09-21 15:22:28 +0000 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2016-09-21 15:22:28 +0000 |
commit | 24fed567876a679be660551afea7677f2ea57665 (patch) | |
tree | 0b6695468e1e1a069845e36200275bf3c2c839ff /spec/controllers | |
parent | ab49c1a3a326ad44cc3481becf0cad9095205703 (diff) | |
parent | e41a3912daaeabe19dc434df8837c9e7d7da7842 (diff) | |
download | gitlab-ce-24fed567876a679be660551afea7677f2ea57665.tar.gz |
Merge branch 'and-you-get-awards' into 'master'
And Snippets get awards
## What does this MR do?
Makes snippets more awesome, by making them awardables
## Why was this MR needed?
Because Snippets were left behind.
## What are the relevant issue numbers?
Closes #17878
See merge request !4456
Diffstat (limited to 'spec/controllers')
-rw-r--r-- | spec/controllers/snippets_controller_spec.rb | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/spec/controllers/snippets_controller_spec.rb b/spec/controllers/snippets_controller_spec.rb index 2a89159c070..41d263a46a4 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,33 @@ describe SnippetsController do end end end + + context 'award emoji on snippets' do + let(:personal_snippet) { create(:personal_snippet, :public, author: user) } + let(:another_user) { create(:user) } + + before do + sign_in(another_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 }.from(0).to(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 }.from(1).to(0) + + expect(response.status).to eq(200) + end + end + end end |