2019-04-15 06:17:05 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-01-06 07:21:49 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe Admin::ServicesController do
|
|
|
|
let(:admin) { create(:admin) }
|
|
|
|
|
2017-06-14 14:18:56 -04:00
|
|
|
before do
|
|
|
|
sign_in(admin)
|
|
|
|
end
|
2017-01-06 07:21:49 -05:00
|
|
|
|
|
|
|
describe 'GET #edit' do
|
2017-08-02 15:55:11 -04:00
|
|
|
let!(:project) { create(:project) }
|
2017-01-06 07:21:49 -05:00
|
|
|
|
|
|
|
Service.available_services_names.each do |service_name|
|
|
|
|
context "#{service_name}" do
|
|
|
|
let!(:service) do
|
2018-07-25 05:30:33 -04:00
|
|
|
service_template = "#{service_name}_service".camelize.constantize
|
2017-01-06 07:21:49 -05:00
|
|
|
service_template.where(template: true).first_or_create
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'successfully displays the template' do
|
2018-12-17 17:52:17 -05:00
|
|
|
get :edit, params: { id: service.id }
|
2017-01-06 07:21:49 -05:00
|
|
|
|
2017-10-19 14:28:19 -04:00
|
|
|
expect(response).to have_gitlab_http_status(200)
|
2017-01-06 07:21:49 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2017-05-04 12:11:28 -04:00
|
|
|
|
|
|
|
describe "#update" do
|
2017-08-02 15:55:11 -04:00
|
|
|
let(:project) { create(:project) }
|
2017-05-04 12:11:28 -04:00
|
|
|
let!(:service) do
|
|
|
|
RedmineService.create(
|
|
|
|
project: project,
|
|
|
|
active: false,
|
|
|
|
template: true,
|
|
|
|
properties: {
|
|
|
|
project_url: 'http://abc',
|
|
|
|
issues_url: 'http://abc',
|
|
|
|
new_issue_url: 'http://abc'
|
|
|
|
}
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2017-05-05 12:01:33 -04:00
|
|
|
it 'calls the propagation worker when service is active' do
|
|
|
|
expect(PropagateServiceTemplateWorker).to receive(:perform_async).with(service.id)
|
2017-05-04 12:11:28 -04:00
|
|
|
|
2018-12-17 17:52:17 -05:00
|
|
|
put :update, params: { id: service.id, service: { active: true } }
|
2017-05-04 12:11:28 -04:00
|
|
|
|
2017-10-19 14:28:19 -04:00
|
|
|
expect(response).to have_gitlab_http_status(302)
|
2017-05-04 12:11:28 -04:00
|
|
|
end
|
|
|
|
|
2017-05-05 12:01:33 -04:00
|
|
|
it 'does not call the propagation worker when service is not active' do
|
|
|
|
expect(PropagateServiceTemplateWorker).not_to receive(:perform_async)
|
2017-05-04 12:11:28 -04:00
|
|
|
|
2018-12-17 17:52:17 -05:00
|
|
|
put :update, params: { id: service.id, service: { properties: {} } }
|
2017-05-04 12:11:28 -04:00
|
|
|
|
2017-10-19 14:28:19 -04:00
|
|
|
expect(response).to have_gitlab_http_status(302)
|
2017-05-04 12:11:28 -04:00
|
|
|
end
|
|
|
|
end
|
2017-01-06 07:21:49 -05:00
|
|
|
end
|