Commit 90719161 authored by Gabriel Mazetto's avatar Gabriel Mazetto

Replicate repository creation in Geo secondary node

parent 904981f7
module Geo
class ScheduleRepoCreateService
attr_reader :id
def initialize(params)
@id = params['project_id']
end
def execute
GeoRepositoryCreateWorker.perform_async(id)
end
end
end
class GeoRepositoryCreateWorker
include Sidekiq::Worker
include GeoQueue
def perform(id)
project = Project.find(id)
project.ensure_dir_exist
project.create_repository unless project.repository_exists?
end
end
---
title: 'Geo: Replicate repository creation in Geo secondary node'
merge_request: 952
author:
......@@ -33,6 +33,9 @@ module API
when 'tag_push'
required_attributes! %w(event_name project_id project)
::Geo::ScheduleWikiRepoUpdateService.new(params).execute
when 'project_create'
required_attributes! %w(event_name project_id)
::Geo::ScheduleRepoCreateService.new(params).execute
when 'project_destroy'
required_attributes! %w(event_name project_id path_with_namespace)
::Geo::ScheduleRepoDestroyService.new(params).execute
......
require 'spec_helper'
describe GeoRepositoryCreateWorker do
let(:user) { create :user }
let(:project) { create :project }
let(:perform!) { subject.perform(project.id) }
context 'when no repository' do
before do
expect(Project).to receive(:find).at_least(:once).with(project.id) { project }
expect(project).to receive(:repository_exists?) { false }
end
it 'creates the repository' do
expect(project).to receive(:create_repository)
perform!
end
end
end
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