Commit 5131a00f authored by Andy Soiron's avatar Andy Soiron

Fix events controller spec indentation

parent b2a333b7
...@@ -57,58 +57,58 @@ RSpec.describe JiraConnect::EventsController do ...@@ -57,58 +57,58 @@ RSpec.describe JiraConnect::EventsController do
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
end end
end end
end
describe '#uninstalled' do describe '#uninstalled' do
let!(:installation) { create(:jira_connect_installation) } let!(:installation) { create(:jira_connect_installation) }
let(:qsh) { Atlassian::Jwt.create_query_string_hash('https://gitlab.test/events/uninstalled', 'POST', 'https://gitlab.test') } 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
subject(:post_uninstalled) { post :uninstalled } before do
request.headers['Authorization'] = "JWT #{auth_token}"
end
context 'when JWT is invalid' do subject(:post_uninstalled) { post :uninstalled }
let(:auth_token) { 'invalid_token' }
it 'returns 403' do context 'when JWT is invalid' do
post_uninstalled let(:auth_token) { 'invalid_token' }
expect(response).to have_gitlab_http_status(:forbidden) it 'returns 403' do
end post_uninstalled
it 'does not delete the installation' do expect(response).to have_gitlab_http_status(:forbidden)
expect { post_uninstalled }.not_to change { JiraConnectInstallation.count }
end
end end
context 'when JWT is valid' do it 'does not delete the installation' do
let(:auth_token) do expect { post_uninstalled }.not_to change { JiraConnectInstallation.count }
Atlassian::Jwt.encode({ iss: installation.client_key, qsh: qsh }, installation.shared_secret) end
end end
let(:jira_base_path) { '/-/jira_connect' }
let(:jira_event_path) { '/-/jira_connect/events/uninstalled' }
it 'calls the DestroyService and returns ok in case of success' do context 'when JWT is valid' do
expect_next_instance_of(JiraConnectInstallations::DestroyService, installation, jira_base_path, jira_event_path) do |destroy_service| let(:auth_token) do
expect(destroy_service).to receive(:execute).and_return(true) Atlassian::Jwt.encode({ iss: installation.client_key, qsh: qsh }, installation.shared_secret)
end 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 end
it 'calls the DestroyService and returns unprocessable_entity in case of failure' do post_uninstalled
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(: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 end
post_uninstalled
expect(response).to have_gitlab_http_status(:unprocessable_entity)
end end
end 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