diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-08-19 09:08:42 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-08-19 09:08:42 +0000 |
commit | b76ae638462ab0f673e5915986070518dd3f9ad3 (patch) | |
tree | bdab0533383b52873be0ec0eb4d3c66598ff8b91 /spec/workers/jira_connect/forward_event_worker_spec.rb | |
parent | 434373eabe7b4be9593d18a585fb763f1e5f1a6f (diff) | |
download | gitlab-ce-b76ae638462ab0f673e5915986070518dd3f9ad3.tar.gz |
Add latest changes from gitlab-org/gitlab@14-2-stable-eev14.2.0-rc42
Diffstat (limited to 'spec/workers/jira_connect/forward_event_worker_spec.rb')
-rw-r--r-- | spec/workers/jira_connect/forward_event_worker_spec.rb | 22 |
1 files changed, 7 insertions, 15 deletions
diff --git a/spec/workers/jira_connect/forward_event_worker_spec.rb b/spec/workers/jira_connect/forward_event_worker_spec.rb index adfc071779a..7de9952a1da 100644 --- a/spec/workers/jira_connect/forward_event_worker_spec.rb +++ b/spec/workers/jira_connect/forward_event_worker_spec.rb @@ -15,23 +15,23 @@ RSpec.describe JiraConnect::ForwardEventWorker do let(:client_key) { '123' } let(:shared_secret) { '123' } - subject { described_class.new.perform(jira_connect_installation.id, base_path, event_path) } + subject(:perform) { described_class.new.perform(jira_connect_installation.id, base_path, event_path) } - it 'forwards the event including the auth header and deletes the installation' do + it 'forwards the event and deletes the installation' do stub_request(:post, event_url) expect(Atlassian::Jwt).to receive(:create_query_string_hash).with(event_url, 'POST', base_url).and_return('some_qsh') expect(Atlassian::Jwt).to receive(:encode).with({ iss: client_key, qsh: 'some_qsh' }, shared_secret).and_return('auth_token') - expect { subject }.to change(JiraConnectInstallation, :count).by(-1) + expect(JiraConnect::RetryRequestWorker).to receive(:perform_async).with(event_url, 'auth_token') - expect(WebMock).to have_requested(:post, event_url).with(headers: { 'Authorization' => 'JWT auth_token' }) + expect { perform }.to change(JiraConnectInstallation, :count).by(-1) end context 'when installation does not exist' do let(:jira_connect_installation) { instance_double(JiraConnectInstallation, id: -1) } it 'does nothing' do - expect { subject }.not_to change(JiraConnectInstallation, :count) + expect { perform }.not_to change(JiraConnectInstallation, :count) end end @@ -39,17 +39,9 @@ RSpec.describe JiraConnect::ForwardEventWorker do let!(:jira_connect_installation) { create(:jira_connect_installation) } it 'forwards the event including the auth header' do - expect { subject }.to change(JiraConnectInstallation, :count).by(-1) + expect { perform }.to change(JiraConnectInstallation, :count).by(-1) - expect(WebMock).not_to have_requested(:post, '*') - end - end - - context 'when it fails to forward the event' do - it 'still deletes the installation' do - allow(Gitlab::HTTP).to receive(:post).and_raise(StandardError) - - expect { subject }.to raise_error(StandardError).and change(JiraConnectInstallation, :count).by(-1) + expect(JiraConnect::RetryRequestWorker).not_to receive(:perform_async) end end end |