gitlab-org--gitlab-foss/spec/services/admin/propagate_service_template_spec.rb

60 lines
1.6 KiB
Ruby
Raw Normal View History

# frozen_string_literal: true
2017-05-04 06:13:33 -04:00
require 'spec_helper'
RSpec.describe Admin::PropagateServiceTemplate do
2017-05-05 12:01:33 -04:00
describe '.propagate' do
let_it_be(:project) { create(:project) }
let!(:service_template) do
PushoverService.create!(
template: true,
2017-05-04 06:13:33 -04:00
active: true,
push_events: false,
2017-05-04 06:13:33 -04:00
properties: {
device: 'MyDevice',
sound: 'mic',
priority: 4,
user_key: 'asdf',
api_key: '123456789'
}
)
2017-05-04 06:13:33 -04:00
end
it 'calls to PropagateIntegrationProjectWorker' do
expect(PropagateIntegrationProjectWorker).to receive(:perform_async)
.with(service_template.id, project.id, project.id)
2017-05-05 12:57:52 -04:00
described_class.propagate(service_template)
2017-05-04 10:41:07 -04:00
end
context 'with a project that has another service' do
before do
BambooService.create!(
active: true,
project: project,
properties: {
bamboo_url: 'http://gitlab.com',
username: 'mic',
password: 'password',
build_key: 'build'
}
)
end
it 'calls to PropagateIntegrationProjectWorker' do
expect(PropagateIntegrationProjectWorker).to receive(:perform_async)
.with(service_template.id, project.id, project.id)
described_class.propagate(service_template)
end
end
2017-05-05 10:16:02 -04:00
it 'does not create the service if it exists already' do
Service.build_from_integration(service_template, project_id: project.id).save!
2017-05-05 10:16:02 -04:00
expect { described_class.propagate(service_template) }
.not_to change { Service.count }
2017-05-05 10:16:02 -04:00
end
2017-05-04 06:13:33 -04:00
end
end