blob: 6c68f36473951bc977cbd7ca86ccb6a5fa6c4ffc (
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
|
require 'spec_helper'
describe Releases::UpdateService do
let(:project) { create(:project, :repository) }
let(:user) { create(:user) }
let(:new_name) { 'A new name' }
let(:new_description) { 'The best release!' }
let(:params) { { name: new_name, description: new_description, tag: tag_name } }
let(:service) { described_class.new(project, user, params) }
let!(:release) { create(:release, project: project, author: user, tag: tag_name) }
let(:tag_name) { 'v1.1.0' }
before do
project.add_developer(user)
end
describe '#execute' do
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)
expect(result[:release].name).to eq(new_name)
expect(result[: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
let!(:release) { }
it_behaves_like 'a failed update'
end
context 'with an invalid update' do
let(:new_description) { '' }
it_behaves_like 'a failed update'
end
end
end
|