2020-04-08 14:13:33 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
RSpec.describe Admin::IntegrationsController do
|
2020-04-08 14:13:33 +05:30
|
|
|
let(:admin) { create(:admin) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
sign_in(admin)
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#edit' do
|
|
|
|
Service.available_services_names.each do |integration_name|
|
|
|
|
context "#{integration_name}" do
|
|
|
|
it 'successfully displays the template' do
|
|
|
|
get :edit, params: { id: integration_name }
|
|
|
|
|
|
|
|
expect(response).to have_gitlab_http_status(:ok)
|
|
|
|
expect(response).to render_template(:edit)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#update' do
|
2020-04-22 19:07:51 +05:30
|
|
|
let(:integration) { create(:jira_service, :instance) }
|
2020-04-08 14:13:33 +05:30
|
|
|
|
|
|
|
before do
|
2020-06-23 00:09:42 +05:30
|
|
|
allow(PropagateIntegrationWorker).to receive(:perform_async)
|
|
|
|
|
|
|
|
put :update, params: { id: integration.class.to_param, overwrite: true, service: { url: url } }
|
2020-04-08 14:13:33 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
context 'valid params' do
|
|
|
|
let(:url) { 'https://jira.gitlab-example.com' }
|
|
|
|
|
|
|
|
it 'updates the integration' do
|
|
|
|
expect(response).to have_gitlab_http_status(:found)
|
|
|
|
expect(integration.reload.url).to eq(url)
|
|
|
|
end
|
2020-06-23 00:09:42 +05:30
|
|
|
|
|
|
|
it 'calls to PropagateIntegrationWorker' do
|
|
|
|
expect(PropagateIntegrationWorker).to have_received(:perform_async).with(integration.id, true)
|
|
|
|
end
|
2020-04-08 14:13:33 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
context 'invalid params' do
|
2020-04-22 19:07:51 +05:30
|
|
|
let(:url) { 'invalid' }
|
2020-04-08 14:13:33 +05:30
|
|
|
|
|
|
|
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)
|
|
|
|
end
|
2020-06-23 00:09:42 +05:30
|
|
|
|
|
|
|
it 'does not call to PropagateIntegrationWorker' do
|
|
|
|
expect(PropagateIntegrationWorker).not_to have_received(:perform_async)
|
|
|
|
end
|
2020-04-08 14:13:33 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|