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/controllers/jira_connect/events_controller_spec.rb | |
parent | fc845b37ec3a90aaa719975f607740c22ba6a113 (diff) |
Add latest changes from gitlab-org/gitlab@14-1-stable-eev14.1.0-rc42
Diffstat (limited to 'spec/controllers/jira_connect/events_controller_spec.rb')
-rw-r--r-- | spec/controllers/jira_connect/events_controller_spec.rb | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/spec/controllers/jira_connect/events_controller_spec.rb b/spec/controllers/jira_connect/events_controller_spec.rb index 8a07f69e480..e9fecb594a7 100644 --- a/spec/controllers/jira_connect/events_controller_spec.rb +++ b/spec/controllers/jira_connect/events_controller_spec.rb @@ -66,19 +66,19 @@ RSpec.describe JiraConnect::EventsController do request.headers['Authorization'] = "JWT #{auth_token}" end - subject { post :uninstalled } + subject(:post_uninstalled) { post :uninstalled } context 'when JWT is invalid' do let(:auth_token) { 'invalid_token' } it 'returns 403' do - subject + post_uninstalled expect(response).to have_gitlab_http_status(:forbidden) end it 'does not delete the installation' do - expect { subject }.not_to change { JiraConnectInstallation.count } + expect { post_uninstalled }.not_to change { JiraConnectInstallation.count } end end @@ -87,8 +87,27 @@ RSpec.describe JiraConnect::EventsController do Atlassian::Jwt.encode({ iss: installation.client_key, qsh: qsh }, installation.shared_secret) end - it 'deletes the installation' do - expect { subject }.to change { JiraConnectInstallation.count }.by(-1) + 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 + 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 + + post_uninstalled + + expect(response).to have_gitlab_http_status(:ok) + 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 + + expect(response).to have_gitlab_http_status(:unprocessable_entity) end end end |