debian-mirror-gitlab/spec/services/admin/propagate_service_template_spec.rb

60 lines
1.6 KiB
Ruby
Raw Normal View History

2019-07-31 22:56:46 +05:30
# frozen_string_literal: true
2017-08-17 22:00:37 +05:30
require 'spec_helper'
2020-11-24 15:15:51 +05:30
RSpec.describe Admin::PropagateServiceTemplate do
2017-08-17 22:00:37 +05:30
describe '.propagate' do
2021-01-03 14:25:43 +05:30
let_it_be(:project) { create(:project) }
2017-08-17 22:00:37 +05:30
let!(:service_template) do
2020-11-24 15:15:51 +05:30
PushoverService.create!(
2017-08-17 22:00:37 +05:30
template: true,
active: true,
2020-05-24 23:13:21 +05:30
push_events: false,
2017-08-17 22:00:37 +05:30
properties: {
device: 'MyDevice',
sound: 'mic',
priority: 4,
user_key: 'asdf',
api_key: '123456789'
2020-05-24 23:13:21 +05:30
}
)
2017-08-17 22:00:37 +05:30
end
2021-01-03 14:25:43 +05:30
it 'calls to PropagateIntegrationProjectWorker' do
expect(PropagateIntegrationProjectWorker).to receive(:perform_async)
.with(service_template.id, project.id, project.id)
2017-08-17 22:00:37 +05:30
described_class.propagate(service_template)
end
2021-01-03 14:25:43 +05:30
context 'with a project that has another service' do
before do
BambooService.create!(
2020-05-24 23:13:21 +05:30
active: true,
2021-01-03 14:25:43 +05:30
project: project,
properties: {
bamboo_url: 'http://gitlab.com',
username: 'mic',
password: 'password',
build_key: 'build'
}
2020-05-24 23:13:21 +05:30
)
end
2021-01-03 14:25:43 +05:30
it 'calls to PropagateIntegrationProjectWorker' do
expect(PropagateIntegrationProjectWorker).to receive(:perform_async)
.with(service_template.id, project.id, project.id)
2017-08-17 22:00:37 +05:30
described_class.propagate(service_template)
end
end
2021-01-03 14:25:43 +05:30
it 'does not create the service if it exists already' do
Service.build_from_integration(service_template, project_id: project.id).save!
2017-08-17 22:00:37 +05:30
2021-01-03 14:25:43 +05:30
expect { described_class.propagate(service_template) }
.not_to change { Service.count }
2017-08-17 22:00:37 +05:30
end
end
end