diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-07 12:09:16 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-07 12:09:16 +0000 |
commit | 0254867cf0f3341fd63cc6da07290f1da91f99ef (patch) | |
tree | 4b3fb556c1cb8cde3459e56d58d5e61eb268d9ec /spec/services/merge_requests | |
parent | c417764f00abaa5d2224a50b8d43a15e40ef8790 (diff) | |
download | gitlab-ce-0254867cf0f3341fd63cc6da07290f1da91f99ef.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/services/merge_requests')
-rw-r--r-- | spec/services/merge_requests/remove_approval_service_spec.rb | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/spec/services/merge_requests/remove_approval_service_spec.rb b/spec/services/merge_requests/remove_approval_service_spec.rb new file mode 100644 index 00000000000..89efd581abf --- /dev/null +++ b/spec/services/merge_requests/remove_approval_service_spec.rb @@ -0,0 +1,37 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe MergeRequests::RemoveApprovalService do + describe '#execute' do + let(:user) { create(:user) } + let(:project) { create(:project) } + let(:merge_request) { create(:merge_request, source_project: project) } + let!(:existing_approval) { create(:approval, merge_request: merge_request) } + + subject(:service) { described_class.new(project, user) } + + def execute! + service.execute(merge_request) + end + + before do + project.add_developer(user) + end + + context 'with a user who has approved' do + let!(:approval) { create(:approval, user: user, merge_request: merge_request) } + + it 'removes the approval' do + expect { execute! }.to change { merge_request.approvals.size }.from(2).to(1) + end + + it 'creates an unapproval note and triggers web hook' do + expect(service).to receive(:execute_hooks).with(merge_request, 'unapproved') + expect(SystemNoteService).to receive(:unapprove_mr) + + execute! + end + end + end +end |