From 7a4b288ec96e64bd9eaf1296d319a39401901df4 Mon Sep 17 00:00:00 2001 From: Peter Leitzen Date: Sat, 21 Jul 2018 14:57:52 +0200 Subject: Create a system note after tagging a commit --- spec/services/commits/update_service_spec.rb | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'spec/services/commits') diff --git a/spec/services/commits/update_service_spec.rb b/spec/services/commits/update_service_spec.rb index cfca3a85236..05d1e4ec254 100644 --- a/spec/services/commits/update_service_spec.rb +++ b/spec/services/commits/update_service_spec.rb @@ -22,11 +22,26 @@ describe Commits::UpdateService do end it 'tags a commit' do + tag_double = double(name: opts[:tag_name]) tag_stub = instance_double(Tags::CreateService) allow(Tags::CreateService).to receive(:new).and_return(tag_stub) allow(tag_stub).to receive(:execute) .with(opts[:tag_name], commit.sha, opts[:tag_message], nil) - .and_return({ status: :success }) + .and_return({ status: :success, tag: tag_double }) + + expect(SystemNoteService).to receive(:tag_commit).with(commit, project, user, opts[:tag_name]) + + service.execute(commit) + end + + it 'fails to tag the commit' do + tag_stub = instance_double(Tags::CreateService) + allow(Tags::CreateService).to receive(:new).and_return(tag_stub) + allow(tag_stub).to receive(:execute) + .with(opts[:tag_name], commit.sha, opts[:tag_message], nil) + .and_return({ status: :error }) + + expect(SystemNoteService).not_to receive(:tag_commit) service.execute(commit) end @@ -39,6 +54,7 @@ describe Commits::UpdateService do it 'does not call the tag create service' do expect(Tags::CreateService).not_to receive(:new) + expect(SystemNoteService).not_to receive(:tag_commit) service.execute(commit) end -- cgit v1.2.1