summaryrefslogtreecommitdiff
path: root/spec/controllers/admin/integrations_controller_spec.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-08-19 09:08:42 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-08-19 09:08:42 +0000
commitb76ae638462ab0f673e5915986070518dd3f9ad3 (patch)
treebdab0533383b52873be0ec0eb4d3c66598ff8b91 /spec/controllers/admin/integrations_controller_spec.rb
parent434373eabe7b4be9593d18a585fb763f1e5f1a6f (diff)
downloadgitlab-ce-b76ae638462ab0f673e5915986070518dd3f9ad3.tar.gz
Add latest changes from gitlab-org/gitlab@14-2-stable-eev14.2.0-rc42
Diffstat (limited to 'spec/controllers/admin/integrations_controller_spec.rb')
-rw-r--r--spec/controllers/admin/integrations_controller_spec.rb46
1 files changed, 41 insertions, 5 deletions
diff --git a/spec/controllers/admin/integrations_controller_spec.rb b/spec/controllers/admin/integrations_controller_spec.rb
index 5a68bb2749b..64ae2a95b4e 100644
--- a/spec/controllers/admin/integrations_controller_spec.rb
+++ b/spec/controllers/admin/integrations_controller_spec.rb
@@ -43,15 +43,15 @@ RSpec.describe Admin::IntegrationsController do
stub_jira_integration_test
allow(PropagateIntegrationWorker).to receive(:perform_async)
- put :update, params: { id: integration.class.to_param, service: { url: url } }
+ put :update, params: { id: integration.class.to_param, service: params }
end
context 'valid params' do
- let(:url) { 'https://jira.gitlab-example.com' }
+ let(:params) { { url: 'https://jira.gitlab-example.com', password: 'password' } }
it 'updates the integration' do
expect(response).to have_gitlab_http_status(:found)
- expect(integration.reload.url).to eq(url)
+ expect(integration.reload).to have_attributes(params)
end
it 'calls to PropagateIntegrationWorker' do
@@ -60,12 +60,12 @@ RSpec.describe Admin::IntegrationsController do
end
context 'invalid params' do
- let(:url) { 'invalid' }
+ let(:params) { { url: 'invalid', password: 'password' } }
it 'does not update the integration' do
expect(response).to have_gitlab_http_status(:ok)
expect(response).to render_template(:edit)
- expect(integration.reload.url).not_to eq(url)
+ expect(integration.reload).not_to have_attributes(params)
end
it 'does not call to PropagateIntegrationWorker' do
@@ -97,4 +97,40 @@ RSpec.describe Admin::IntegrationsController do
.and change { Integrations::Jira.inherit_from_id(integration.id).count }.by(-1)
end
end
+
+ describe '#overrides' do
+ let_it_be(:instance_integration) { create(:bugzilla_integration, :instance) }
+ let_it_be(:non_overridden_integration) { create(:bugzilla_integration, inherit_from_id: instance_integration.id) }
+ let_it_be(:overridden_integration) { create(:bugzilla_integration) }
+ let_it_be(:overridden_other_integration) { create(:confluence_integration) }
+
+ subject do
+ get :overrides, params: { id: instance_integration.class.to_param }, format: format
+ end
+
+ context 'when format is JSON' do
+ let(:format) { :json }
+
+ include_context 'JSON response'
+
+ it 'returns projects with overrides', :aggregate_failures do
+ subject
+
+ expect(response).to have_gitlab_http_status(:ok)
+ expect(response).to include_pagination_headers
+ expect(json_response).to contain_exactly(a_hash_including('full_name' => overridden_integration.project.full_name))
+ end
+ end
+
+ context 'when format is HTML' do
+ let(:format) { :html }
+
+ it 'renders template' do
+ subject
+
+ expect(response).to render_template 'shared/integrations/overrides'
+ expect(assigns(:integration)).to eq(instance_integration)
+ end
+ end
+ end
end