gitlab-org--gitlab-foss/spec/controllers/admin/services_controller_spec.rb

76 lines
2 KiB
Ruby
Raw Normal View History

# frozen_string_literal: true
2017-01-06 07:21:49 -05:00
require 'spec_helper'
RSpec.describe Admin::ServicesController do
2017-01-06 07:21:49 -05:00
let(:admin) { create(:admin) }
before do
sign_in(admin)
end
2017-01-06 07:21:49 -05:00
describe 'GET #edit' do
let(:service) do
create(:jira_service, :template)
end
2017-01-06 07:21:49 -05:00
it 'successfully displays the template' do
get :edit, params: { id: service.id }
2017-01-06 07:21:49 -05:00
expect(response).to have_gitlab_http_status(:ok)
2017-01-06 07:21:49 -05:00
end
context 'when integration does not exists' do
it 'redirects to the admin application integration page' do
get :edit, params: { id: 'invalid' }
expect(response).to redirect_to(admin_application_settings_services_path)
end
end
context 'when instance integration exists' do
before do
create(:jira_service, :instance)
end
it 'redirects to the admin application integration page' do
get :edit, params: { id: service.id }
expect(response).to redirect_to(admin_application_settings_services_path)
end
end
2017-01-06 07:21:49 -05:00
end
describe "#update" do
let(:project) { create(:project) }
let!(:service_template) do
RedmineService.create(
project: nil,
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_template.id)
put :update, params: { id: service_template.id, service: { active: true } }
expect(response).to have_gitlab_http_status(:found)
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)
put :update, params: { id: service_template.id, service: { properties: {} } }
expect(response).to have_gitlab_http_status(:found)
end
end
2017-01-06 07:21:49 -05:00
end