summaryrefslogtreecommitdiff
path: root/spec/services/jira_connect_installations/destroy_service_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/services/jira_connect_installations/destroy_service_spec.rb')
-rw-r--r--spec/services/jira_connect_installations/destroy_service_spec.rb41
1 files changed, 41 insertions, 0 deletions
diff --git a/spec/services/jira_connect_installations/destroy_service_spec.rb b/spec/services/jira_connect_installations/destroy_service_spec.rb
new file mode 100644
index 00000000000..bb5bab53ccb
--- /dev/null
+++ b/spec/services/jira_connect_installations/destroy_service_spec.rb
@@ -0,0 +1,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