diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-10 18:07:43 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-10 18:07:43 +0000 |
commit | 6f0f893bd87535b61e0ecb1ce069eaa7fcb9e5be (patch) | |
tree | 8af92b29c838e9af2fd70f9a4a2314a08f4af922 /spec/services | |
parent | 8b1228b0d409d7751f01d9fb72ebfbbf62399486 (diff) | |
download | gitlab-ce-6f0f893bd87535b61e0ecb1ce069eaa7fcb9e5be.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/services')
-rw-r--r-- | spec/services/releases/update_service_spec.rb | 38 |
1 files changed, 27 insertions, 11 deletions
diff --git a/spec/services/releases/update_service_spec.rb b/spec/services/releases/update_service_spec.rb index 178bac3574f..f6c70873540 100644 --- a/spec/services/releases/update_service_spec.rb +++ b/spec/services/releases/update_service_spec.rb @@ -21,6 +21,7 @@ describe Releases::UpdateService do it 'raises an error' do result = service.execute expect(result[:status]).to eq(:error) + expect(result[:milestones_updated]).to be_falsy end end @@ -50,21 +51,33 @@ describe Releases::UpdateService do end context 'when a milestone is passed in' do - let(:new_title) { 'v2.0' } let(:milestone) { create(:milestone, project: project, title: 'v1.0') } - let(:new_milestone) { create(:milestone, project: project, title: new_title) } let(:params_with_milestone) { params.merge!({ milestones: [new_title] }) } + let(:new_milestone) { create(:milestone, project: project, title: new_title) } let(:service) { described_class.new(new_milestone.project, user, params_with_milestone) } before do release.milestones << milestone + end - service.execute - release.reload + context 'a different milestone' do + let(:new_title) { 'v2.0' } + + it 'updates the related milestone accordingly' do + result = service.execute + release.reload + + expect(release.milestones.first.title).to eq(new_title) + expect(result[:milestones_updated]).to be_truthy + end end - it 'updates the related milestone accordingly' do - expect(release.milestones.first.title).to eq(new_title) + context 'an identical milestone' do + let(:new_title) { 'v1.0' } + + it "raises an error" do + expect { service.execute }.to raise_error(ActiveRecord::RecordInvalid) + end end end @@ -76,12 +89,14 @@ describe Releases::UpdateService do release.milestones << milestone service.params = params_with_empty_milestone - service.execute - release.reload end it 'removes the old milestone and does not associate any new milestone' do + result = service.execute + release.reload + expect(release.milestones).not_to be_present + expect(result[:milestones_updated]).to be_truthy end end @@ -96,14 +111,15 @@ describe Releases::UpdateService do create(:milestone, project: project, title: new_title_1) create(:milestone, project: project, title: new_title_2) release.milestones << milestone - - service.execute - release.reload end it 'removes the old milestone and update the release with the new ones' do + result = service.execute + release.reload + milestone_titles = release.milestones.map(&:title) expect(milestone_titles).to match_array([new_title_1, new_title_2]) + expect(result[:milestones_updated]).to be_truthy end end end |