Commit d27c5f82 authored by Patricio Cano's avatar Patricio Cano

Fixed specs and added TODOs to mark which pieces of code need to be fixed on the next iteration.

parent 2aef8c6e
# TODO: Remove me once Geo is fixed
class GeoRepositoryFetchWorker class GeoRepositoryFetchWorker
include Sidekiq::Worker include Sidekiq::Worker
include Gitlab::ShellAdapter include Gitlab::ShellAdapter
......
...@@ -9,11 +9,19 @@ class GeoRepositoryUpdateWorker ...@@ -9,11 +9,19 @@ class GeoRepositoryUpdateWorker
@project = Project.find(project_id) @project = Project.find(project_id)
@push_data = push_data @push_data = push_data
# TODO: Enable fetch once Geo is fixed
# fetch_repository(clone_url)
process_hooks if push_data # we should be compatible with old unprocessed data process_hooks if push_data # we should be compatible with old unprocessed data
end end
private private
def fetch_repository(remote_url)
@project.create_repository unless @project.repository_exists?
@project.repository.after_create if @project.empty_repo?
@project.repository.fetch_geo_mirror(remote_url)
end
def process_hooks def process_hooks
if @push_data['type'] == 'push' if @push_data['type'] == 'push'
branch = Gitlab::Git.ref_name(@push_data['ref']) branch = Gitlab::Git.ref_name(@push_data['ref'])
......
...@@ -27,6 +27,7 @@ class PostReceive ...@@ -27,6 +27,7 @@ class PostReceive
# Triggers repository update on secondary nodes when Geo is enabled # Triggers repository update on secondary nodes when Geo is enabled
Gitlab::Geo.notify_wiki_update(post_received.project) if Gitlab::Geo.enabled? Gitlab::Geo.notify_wiki_update(post_received.project) if Gitlab::Geo.enabled?
elsif post_received.regular_project? elsif post_received.regular_project?
# TODO: Remove this if block once Geo is fixed
if Gitlab::Geo.enabled? if Gitlab::Geo.enabled?
hook_data = { hook_data = {
project_id: post_received.project.id, project_id: post_received.project.id,
......
require 'spec_helper'
# TODO: Remove me once Geo is fixed
describe GeoRepositoryFetchWorker do
describe '#perform' do
let(:project) { create(:empty_project) }
before do
allow_any_instance_of(Gitlab::Geo).to receive_messages(secondary?: true)
allow_any_instance_of(Repository).to receive(:fetch_geo_mirror).and_return(true)
allow_any_instance_of(Project).to receive(:repository_exists?) { false }
allow_any_instance_of(Project).to receive(:empty_repo?) { true }
end
it 'creates a new repository' do
expect_any_instance_of(Project).to receive(:create_repository)
perform
end
it 'executes after_create hook' do
expect_any_instance_of(Repository).to receive(:after_create).at_least(:once)
perform
end
it 'fetches the Geo mirror' do
expect_any_instance_of(Repository).to receive(:fetch_geo_mirror)
perform
end
end
def perform
subject.perform(project.id, project.ssh_url_to_repo)
end
end
...@@ -36,13 +36,15 @@ describe GeoRepositoryUpdateWorker do ...@@ -36,13 +36,15 @@ describe GeoRepositoryUpdateWorker do
allow(project).to receive(:repository_exists?) { false } allow(project).to receive(:repository_exists?) { false }
end end
it 'creates a new repository' do # TODO: Enable again once Geo update has been properly fixed.
# See !1015 for more info
xit 'creates a new repository' do
expect(project).to receive(:create_repository) expect(project).to receive(:create_repository)
performed performed
end end
it 'executes after_create hook' do xit 'executes after_create hook' do
expect(project.repository).to receive(:after_create) expect(project.repository).to receive(:after_create)
performed performed
......
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