summaryrefslogtreecommitdiff
path: root/spec/services/commits
diff options
context:
space:
mode:
authorPeter Leitzen <pl@neopoly.de>2018-07-30 13:25:51 +0200
committerPeter Leitzen <pl@neopoly.de>2018-08-10 16:45:11 +0200
commitfbd0f162524b6dd875097f76e1175a55dba5f3f6 (patch)
treef515ae38c688fea6a1da4b95beac9c26a8bea521 /spec/services/commits
parent9c6fc59c6c95f8439e47d62eb4fd4b11f8d0acdc (diff)
downloadgitlab-ce-fbd0f162524b6dd875097f76e1175a55dba5f3f6.tar.gz
Let Commits::TagService return a result hash
Diffstat (limited to 'spec/services/commits')
-rw-r--r--spec/services/commits/tag_service_spec.rb33
1 files changed, 23 insertions, 10 deletions
diff --git a/spec/services/commits/tag_service_spec.rb b/spec/services/commits/tag_service_spec.rb
index 5e778681544..f14eb9ea2b9 100644
--- a/spec/services/commits/tag_service_spec.rb
+++ b/spec/services/commits/tag_service_spec.rb
@@ -13,11 +13,12 @@ describe Commits::TagService do
describe '#execute' do
let(:service) { described_class.new(project, user, opts) }
- shared_examples 'tagging fails' do
- it 'returns nil' do
- tagged_commit = service.execute(commit)
+ shared_examples 'tag failure' do
+ it 'returns a hash with the :error status' do
+ result = service.execute(commit)
- expect(tagged_commit).to be_nil
+ expect(result[:status]).to eq(:error)
+ expect(result[:message]).to eq(error_message)
end
it 'does not add a system note' do
@@ -51,10 +52,14 @@ describe Commits::TagService do
end
context 'when tagging succeeds' do
- it 'returns the commit' do
- tagged_commit = service.execute(commit)
+ it 'returns a hash with the :success status and created tag' do
+ result = service.execute(commit)
- expect(tagged_commit).to eq(commit)
+ expect(result[:status]).to eq(:success)
+
+ tag = result[:tag]
+ expect(tag.name).to eq(opts[:tag_name])
+ expect(tag.message).to eq(opts[:tag_message])
end
it 'adds a system note' do
@@ -66,13 +71,19 @@ describe Commits::TagService do
end
context 'when tagging fails' do
+ let(:tag_error) { 'GitLab: You are not allowed to push code to this project.' }
+
before do
tag_stub = instance_double(Tags::CreateService)
allow(Tags::CreateService).to receive(:new).and_return(tag_stub)
- allow(tag_stub).to receive(:execute).and_return({ status: :error })
+ allow(tag_stub).to receive(:execute).and_return({
+ status: :error, message: tag_error
+ })
end
- include_examples 'tagging fails'
+ it_behaves_like 'tag failure' do
+ let(:error_message) { tag_error }
+ end
end
end
@@ -81,7 +92,9 @@ describe Commits::TagService do
{}
end
- include_examples 'tagging fails'
+ it_behaves_like 'tag failure' do
+ let(:error_message) { 'Missing parameter tag_name' }
+ end
end
end
end