blob: a24dcabfc2e861eb261ae25e0c22fc346b6b4d2d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
require 'spec_helper'
describe UpdateReleaseService do
let(:project) { create(:project, :repository) }
let(:user) { create(:user) }
let(:tag_name) { project.repository.tag_names.first }
let(:description) { 'Awesome release!' }
let(:new_name) { 'A new name' }
let(:new_description) { 'The best release!' }
let(:params) { { name: new_name, description: new_description } }
let(:service) { described_class.new(project, user, tag_name, params) }
let(:create_service) { CreateReleaseService.new(project, user) }
before do
create_service.execute(tag_name, description)
end
shared_examples 'a failed update' do
it 'raises an error' do
result = service.execute
expect(result[:status]).to eq(:error)
end
end
it 'successfully updates an existing release' do
result = service.execute
expect(result[:status]).to eq(:success)
release = project.releases.find_by(tag: tag_name)
expect(release.name).to eq(new_name)
expect(release.description).to eq(new_description)
end
context 'when the tag does not exists' do
let(:tag_name) { 'foobar' }
it_behaves_like 'a failed update'
end
context 'when the release does not exist' do
before do
project.releases.delete_all
end
it_behaves_like 'a failed update'
end
context 'with an invalid update' do
let(:new_description) { '' }
it_behaves_like 'a failed update'
end
end
|