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 # frozen_string_literal: true
module Projects module Admin
class PropagateServiceTemplate class PropagateServiceTemplate
BATCH_SIZE = 100 BATCH_SIZE = 100
......
...@@ -12,7 +12,7 @@ class PropagateServiceTemplateWorker # rubocop:disable Scalability/IdempotentWor ...@@ -12,7 +12,7 @@ class PropagateServiceTemplateWorker # rubocop:disable Scalability/IdempotentWor
def perform(template_id) def perform(template_id)
return unless try_obtain_lease_for(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 end
# rubocop: enable CodeReuse/ActiveRecord # rubocop: enable CodeReuse/ActiveRecord
......
...@@ -2,10 +2,10 @@ ...@@ -2,10 +2,10 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe Projects::PropagateServiceTemplate do RSpec.describe Admin::PropagateServiceTemplate do
describe '.propagate' do describe '.propagate' do
let!(:service_template) do let!(:service_template) do
PushoverService.create( PushoverService.create!(
template: true, template: true,
active: true, active: true,
push_events: false, push_events: false,
...@@ -31,8 +31,7 @@ RSpec.describe Projects::PropagateServiceTemplate do ...@@ -31,8 +31,7 @@ RSpec.describe Projects::PropagateServiceTemplate do
end end
it 'creates services for a project that has another service' do it 'creates services for a project that has another service' do
BambooService.create( BambooService.create!(
template: true,
active: true, active: true,
project: project, project: project,
properties: { properties: {
...@@ -51,7 +50,7 @@ RSpec.describe Projects::PropagateServiceTemplate do ...@@ -51,7 +50,7 @@ RSpec.describe Projects::PropagateServiceTemplate do
end end
it 'does not create the service if it exists already' do it 'does not create the service if it exists already' do
other_service = BambooService.create( other_service = BambooService.create!(
template: true, template: true,
active: true, active: true,
properties: { properties: {
...@@ -110,7 +109,7 @@ RSpec.describe Projects::PropagateServiceTemplate do ...@@ -110,7 +109,7 @@ RSpec.describe Projects::PropagateServiceTemplate do
let(:project_total) { 5 } let(:project_total) { 5 }
before do before do
stub_const 'Projects::PropagateServiceTemplate::BATCH_SIZE', 3 stub_const('Admin::PropagateServiceTemplate::BATCH_SIZE', 3)
project_total.times { create(:project) } project_total.times { create(:project) }
......
...@@ -21,7 +21,7 @@ RSpec.describe PropagateServiceTemplateWorker do ...@@ -21,7 +21,7 @@ RSpec.describe PropagateServiceTemplateWorker do
stub_exclusive_lease("propagate_service_template_worker:#{template.id}", stub_exclusive_lease("propagate_service_template_worker:#{template.id}",
timeout: PropagateServiceTemplateWorker::LEASE_TIMEOUT) timeout: PropagateServiceTemplateWorker::LEASE_TIMEOUT)
expect(Projects::PropagateServiceTemplate) expect(Admin::PropagateServiceTemplate)
.to receive(:propagate) .to receive(:propagate)
.with(template) .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