Commit 896c02a4 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'fix-jira-connect-events-controller-spec-indentation' into 'master'

Fix Jira connect events controller spec indentation

See merge request gitlab-org/gitlab!70940
parents c09574d0 5131a00f
......@@ -57,58 +57,58 @@ RSpec.describe JiraConnect::EventsController do
expect(response).to have_gitlab_http_status(:ok)
end
end
end
describe '#uninstalled' do
let!(:installation) { create(:jira_connect_installation) }
let(:qsh) { Atlassian::Jwt.create_query_string_hash('https://gitlab.test/events/uninstalled', 'POST', 'https://gitlab.test') }
before do
request.headers['Authorization'] = "JWT #{auth_token}"
end
describe '#uninstalled' do
let!(:installation) { create(:jira_connect_installation) }
let(:qsh) { Atlassian::Jwt.create_query_string_hash('https://gitlab.test/events/uninstalled', 'POST', 'https://gitlab.test') }
subject(:post_uninstalled) { post :uninstalled }
before do
request.headers['Authorization'] = "JWT #{auth_token}"
end
context 'when JWT is invalid' do
let(:auth_token) { 'invalid_token' }
subject(:post_uninstalled) { post :uninstalled }
it 'returns 403' do
post_uninstalled
context 'when JWT is invalid' do
let(:auth_token) { 'invalid_token' }
expect(response).to have_gitlab_http_status(:forbidden)
end
it 'returns 403' do
post_uninstalled
it 'does not delete the installation' do
expect { post_uninstalled }.not_to change { JiraConnectInstallation.count }
end
expect(response).to have_gitlab_http_status(:forbidden)
end
context 'when JWT is valid' do
let(:auth_token) do
Atlassian::Jwt.encode({ iss: installation.client_key, qsh: qsh }, installation.shared_secret)
end
let(:jira_base_path) { '/-/jira_connect' }
let(:jira_event_path) { '/-/jira_connect/events/uninstalled' }
it 'does not delete the installation' do
expect { post_uninstalled }.not_to change { JiraConnectInstallation.count }
end
end
it 'calls the DestroyService and returns ok in case of success' do
expect_next_instance_of(JiraConnectInstallations::DestroyService, installation, jira_base_path, jira_event_path) do |destroy_service|
expect(destroy_service).to receive(:execute).and_return(true)
end
context 'when JWT is valid' do
let(:auth_token) do
Atlassian::Jwt.encode({ iss: installation.client_key, qsh: qsh }, installation.shared_secret)
end
post_uninstalled
let(:jira_base_path) { '/-/jira_connect' }
let(:jira_event_path) { '/-/jira_connect/events/uninstalled' }
expect(response).to have_gitlab_http_status(:ok)
it 'calls the DestroyService and returns ok in case of success' do
expect_next_instance_of(JiraConnectInstallations::DestroyService, installation, jira_base_path, jira_event_path) do |destroy_service|
expect(destroy_service).to receive(:execute).and_return(true)
end
it 'calls the DestroyService and returns unprocessable_entity in case of failure' do
expect_next_instance_of(JiraConnectInstallations::DestroyService, installation, jira_base_path, jira_event_path) do |destroy_service|
expect(destroy_service).to receive(:execute).and_return(false)
end
post_uninstalled
post_uninstalled
expect(response).to have_gitlab_http_status(:ok)
end
expect(response).to have_gitlab_http_status(:unprocessable_entity)
it 'calls the DestroyService and returns unprocessable_entity in case of failure' do
expect_next_instance_of(JiraConnectInstallations::DestroyService, installation, jira_base_path, jira_event_path) do |destroy_service|
expect(destroy_service).to receive(:execute).and_return(false)
end
post_uninstalled
expect(response).to have_gitlab_http_status(:unprocessable_entity)
end
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment