diff options
author | Felipe Artur <felipefac@gmail.com> | 2017-07-10 20:57:16 +0300 |
---|---|---|
committer | Felipe Artur <felipefac@gmail.com> | 2017-07-10 20:59:34 +0300 |
commit | 0f7cb967839c6b939f6a8ce8d15c6925acb41031 (patch) | |
tree | 680a14badab4f4e10f3690d2bdf8f46b0386a993 /spec/services/milestones/destroy_service_spec.rb | |
parent | 31ada792621f17ab7f4f7475405ddd1ec9e9673a (diff) |
Fix milestones destroy service
Diffstat (limited to 'spec/services/milestones/destroy_service_spec.rb')
-rw-r--r-- | spec/services/milestones/destroy_service_spec.rb | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/spec/services/milestones/destroy_service_spec.rb b/spec/services/milestones/destroy_service_spec.rb new file mode 100644 index 00000000000..8d1fe3ae2c1 --- /dev/null +++ b/spec/services/milestones/destroy_service_spec.rb @@ -0,0 +1,51 @@ +require 'spec_helper' + +describe Milestones::DestroyService, services: true do + let(:user) { create(:user) } + let(:project) { create(:project) } + let(:milestone) { create(:milestone, title: 'Milestone v1.0', project: project) } + let(:issue) { create(:issue, project: project, milestone: milestone) } + let(:merge_request) { create(:merge_request, source_project: project, milestone: milestone) } + + before do + project.team << [user, :master] + end + + def service + described_class.new(project, user, {}) + end + + describe '#execute' do + it 'deletes milestone' do + service.execute(milestone) + + expect { milestone.reload }.to raise_error ActiveRecord::RecordNotFound + end + + it 'deletes milestone id from issuables' do + service.execute(milestone) + + expect(issue.reload.milestone).to be_nil + expect(merge_request.reload.milestone).to be_nil + end + + context 'group milestones' do + let(:group) { create(:group) } + let(:group_milestone) { create(:milestone, group: group) } + + before do + project.update(namespace: group) + group.add_developer(user) + end + + it { expect(service.execute(group_milestone)).to be_nil } + + it 'does not update milestone issuables' do + expect(MergeRequests::UpdateService).not_to receive(:new) + expect(Issues::UpdateService).not_to receive(:new) + + service.execute(group_milestone) + end + end + end +end |