Commit edccbcb6 authored by Arturo Herrero's avatar Arturo Herrero

Update module for PropagateServiceTemplate

This is consistent with PropagateIntegrationService.
parent 10013895
# frozen_string_literal: true
module Projects
module Admin
class PropagateServiceTemplate
BATCH_SIZE = 100
......
......@@ -12,7 +12,7 @@ class PropagateServiceTemplateWorker # rubocop:disable Scalability/IdempotentWor
def perform(template_id)
return unless try_obtain_lease_for(template_id)
Projects::PropagateServiceTemplate.propagate(Service.find_by(id: template_id))
Admin::PropagateServiceTemplate.propagate(Service.find_by(id: template_id))
end
# rubocop: enable CodeReuse/ActiveRecord
......
......@@ -2,10 +2,10 @@
require 'spec_helper'
RSpec.describe Projects::PropagateServiceTemplate do
RSpec.describe Admin::PropagateServiceTemplate do
describe '.propagate' do
let!(:service_template) do
PushoverService.create(
PushoverService.create!(
template: true,
active: true,
push_events: false,
......@@ -31,8 +31,7 @@ RSpec.describe Projects::PropagateServiceTemplate do
end
it 'creates services for a project that has another service' do
BambooService.create(
template: true,
BambooService.create!(
active: true,
project: project,
properties: {
......@@ -51,7 +50,7 @@ RSpec.describe Projects::PropagateServiceTemplate do
end
it 'does not create the service if it exists already' do
other_service = BambooService.create(
other_service = BambooService.create!(
template: true,
active: true,
properties: {
......@@ -110,7 +109,7 @@ RSpec.describe Projects::PropagateServiceTemplate do
let(:project_total) { 5 }
before do
stub_const 'Projects::PropagateServiceTemplate::BATCH_SIZE', 3
stub_const('Admin::PropagateServiceTemplate::BATCH_SIZE', 3)
project_total.times { create(:project) }
......
......@@ -21,7 +21,7 @@ RSpec.describe PropagateServiceTemplateWorker do
stub_exclusive_lease("propagate_service_template_worker:#{template.id}",
timeout: PropagateServiceTemplateWorker::LEASE_TIMEOUT)
expect(Projects::PropagateServiceTemplate)
expect(Admin::PropagateServiceTemplate)
.to receive(:propagate)
.with(template)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment