diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-07-20 12:55:51 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-07-20 12:55:51 +0300 |
commit | e8d2c2579383897a1dd7f9debd359abe8ae8373d (patch) | |
tree | c42be41678c2586d49a75cabce89322082698334 /spec/services/jira_connect_installations | |
parent | fc845b37ec3a90aaa719975f607740c22ba6a113 (diff) |
Add latest changes from gitlab-org/gitlab@14-1-stable-eev14.1.0-rc42
Diffstat (limited to 'spec/services/jira_connect_installations')
-rw-r--r-- | spec/services/jira_connect_installations/destroy_service_spec.rb | 41 |
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 |