Welcome to mirror list, hosted at ThFree Co, Russian Federation.

execute_approval_hooks_service_spec.rb « merge_requests « services « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 863c47e8191e6cda7dc4e5cebec2539b0b64aa6e (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
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe MergeRequests::ExecuteApprovalHooksService do
  let(:user) { create(:user) }
  let(:merge_request) { create(:merge_request) }
  let(:project) { merge_request.project }

  subject(:service) { described_class.new(project: project, current_user: user) }

  describe '#execute' do
    let(:notification_service) { NotificationService.new }

    before do
      allow(service).to receive(:notification_service).and_return(notification_service)
    end
    it 'sends a notification when approving' do
      expect(notification_service).to receive_message_chain(:async, :approve_mr)
        .with(merge_request, user)

      service.execute(merge_request)
    end

    context 'with remaining approvals' do
      it 'fires an approval webhook' do
        expect(service).to receive(:execute_hooks).with(merge_request, 'approved')

        service.execute(merge_request)
      end
    end
  end
end