diff options
author | George Andrinopoulos <geoandri@gmail.com> | 2017-11-25 17:04:45 +0200 |
---|---|---|
committer | George Andrinopoulos <geoandri@gmail.com> | 2017-11-25 22:09:18 +0200 |
commit | 7fb1bb01bd669cc46514ed17b1b8822a1d962970 (patch) | |
tree | b6206b0a2e290e3254bff1475dfef0caf66503d4 /spec/services/issuable/destroy_service_spec.rb | |
parent | d199ecd452a3bfdc8ba7b4a0ae244a282c047c9f (diff) | |
download | gitlab-ce-7fb1bb01bd669cc46514ed17b1b8822a1d962970.tar.gz |
Create issue and merge request destroy services
Diffstat (limited to 'spec/services/issuable/destroy_service_spec.rb')
-rw-r--r-- | spec/services/issuable/destroy_service_spec.rb | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/spec/services/issuable/destroy_service_spec.rb b/spec/services/issuable/destroy_service_spec.rb new file mode 100644 index 00000000000..d74d98c6079 --- /dev/null +++ b/spec/services/issuable/destroy_service_spec.rb @@ -0,0 +1,38 @@ +require 'spec_helper' + +describe Issuable::DestroyService do + let(:user) { create(:user) } + let(:project) { create(:project) } + + subject(:service) { described_class.new(project, user) } + + describe '#execute' do + context 'when issuable is an issue' do + let!(:issue) { create(:issue, project: project, author: user) } + + it 'destroys the issue' do + expect { service.execute(issue) }.to change { project.issues.count }.by(-1) + end + + it 'updates open issues count cache' do + expect_any_instance_of(Projects::OpenIssuesCountService).to receive(:refresh_cache) + + service.execute(issue) + end + end + + context 'when issuable is a merge request' do + let!(:merge_request) { create(:merge_request, target_project: project, source_project: project, author: user) } + + it 'destroys the merge request' do + expect { service.execute(merge_request) }.to change { project.merge_requests.count }.by(-1) + end + + it 'updates open merge requests count cache' do + expect_any_instance_of(Projects::OpenMergeRequestsCountService).to receive(:refresh_cache) + + service.execute(merge_request) + end + end + end +end |