summaryrefslogtreecommitdiff
path: root/spec/controllers
diff options
context:
space:
mode:
authorZ.J. van de Weg <zegerjan@gitlab.com>2016-09-07 14:48:43 +0200
committerFatih Acet <acetfatih@gmail.com>2016-09-19 19:53:09 +0300
commite8dd0d54cb1e82d142978224a4e062a705cae2cf (patch)
treefada10ed9931976930db159f0c385d186a718f6d /spec/controllers
parent412ff80b7b1381485a306df240aab020e9b90801 (diff)
downloadgitlab-ce-e8dd0d54cb1e82d142978224a4e062a705cae2cf.tar.gz
Fix tests for Snippets toggling awards
Also incorporate feedback
Diffstat (limited to 'spec/controllers')
-rw-r--r--spec/controllers/snippets_controller_spec.rb10
1 files changed, 6 insertions, 4 deletions
diff --git a/spec/controllers/snippets_controller_spec.rb b/spec/controllers/snippets_controller_spec.rb
index 2ea57e50e76..41d263a46a4 100644
--- a/spec/controllers/snippets_controller_spec.rb
+++ b/spec/controllers/snippets_controller_spec.rb
@@ -232,26 +232,28 @@ describe SnippetsController do
end
context 'award emoji on snippets' do
- let(:personal_snippet) { create(:personal_snippet, :private, author: user) }
+ let(:personal_snippet) { create(:personal_snippet, :public, author: user) }
+ let(:another_user) { create(:user) }
before do
- sign_in(user)
+ 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 }.by(1)
+ 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 }.by(-1)
+ end.to change { personal_snippet.award_emoji.count }.from(1).to(0)
expect(response.status).to eq(200)
end