blob: bb5bab53ccb0dd30b08bf51ccbc31055b67b1adc (
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
34
35
36
37
38
39
40
41
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe JiraConnectInstallations::DestroyService do
describe '.execute' do
it 'creates an instance and calls execute' do
expect_next_instance_of(described_class, 'param1', 'param2', 'param3') do |destroy_service|
expect(destroy_service).to receive(:execute)
end
described_class.execute('param1', 'param2', 'param3')
end
end
describe '#execute' do
let!(:installation) { create(:jira_connect_installation) }
let(:jira_base_path) { '/-/jira_connect' }
let(:jira_event_path) { '/-/jira_connect/events/uninstalled' }
subject { described_class.new(installation, jira_base_path, jira_event_path).execute }
it { is_expected.to be_truthy }
it 'deletes the installation' do
expect { subject }.to change(JiraConnectInstallation, :count).by(-1)
end
context 'and the installation has an instance_url set' do
let!(:installation) { create(:jira_connect_installation, instance_url: 'http://example.com') }
it { is_expected.to be_truthy }
it 'schedules a ForwardEventWorker background job and keeps the installation' do
expect(JiraConnect::ForwardEventWorker).to receive(:perform_async).with(installation.id, jira_base_path, jira_event_path)
expect { subject }.not_to change(JiraConnectInstallation, :count)
end
end
end
end
|