debian-mirror-gitlab/spec/controllers/admin/services_controller_spec.rb

61 lines
1.5 KiB
Ruby
Raw Normal View History

2017-08-17 22:00:37 +05:30
require 'spec_helper'
describe Admin::ServicesController do
let(:admin) { create(:admin) }
2017-09-10 17:25:29 +05:30
before do
sign_in(admin)
end
2017-08-17 22:00:37 +05:30
describe 'GET #edit' do
2017-09-10 17:25:29 +05:30
let!(:project) { create(:project) }
2017-08-17 22:00:37 +05:30
Service.available_services_names.each do |service_name|
context "#{service_name}" do
let!(:service) do
service_template = service_name.concat("_service").camelize.constantize
service_template.where(template: true).first_or_create
end
it 'successfully displays the template' do
get :edit, id: service.id
2018-03-17 18:26:18 +05:30
expect(response).to have_gitlab_http_status(200)
2017-08-17 22:00:37 +05:30
end
end
end
end
describe "#update" do
2017-09-10 17:25:29 +05:30
let(:project) { create(:project) }
2017-08-17 22:00:37 +05:30
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
it 'calls the propagation worker when service is active' do
expect(PropagateServiceTemplateWorker).to receive(:perform_async).with(service.id)
put :update, id: service.id, service: { active: true }
2018-03-17 18:26:18 +05:30
expect(response).to have_gitlab_http_status(302)
2017-08-17 22:00:37 +05:30
end
it 'does not call the propagation worker when service is not active' do
expect(PropagateServiceTemplateWorker).not_to receive(:perform_async)
put :update, id: service.id, service: { properties: {} }
2018-03-17 18:26:18 +05:30
expect(response).to have_gitlab_http_status(302)
2017-08-17 22:00:37 +05:30
end
end
end