Commit 648504fa authored by Michael Kozono's avatar Michael Kozono

Merge branch '250315-fix-create-repository-updated-events' into 'master'

Geo - Create repository updated events only if the repository exists

Closes #250315

See merge request gitlab-org/gitlab!42519
parents ddfe5919 cad600ad
......@@ -10,6 +10,7 @@ module Geo
def initialize(repository, params = {})
@project = repository.project
@repository = repository
@params = params
@refs = params.fetch(:refs, [])
@changes = params.fetch(:changes, [])
......@@ -27,11 +28,13 @@ module Geo
private
attr_reader :project, :refs, :changes, :source
attr_reader :project, :repository, :refs, :changes, :source
delegate :repository_state, to: :project
def create_repository_updated_event!
return unless repository.exists?
Geo::RepositoryUpdatedEventStore.new(
project, refs: refs, changes: changes, source: source
).create!
......
---
title: Geo - Create repository updated events only if the repository exists
merge_request: 42519
author:
type: fixed
......@@ -37,10 +37,18 @@ RSpec.describe Geo::RepositoryUpdatedService do
end
context 'when running on a primary node' do
it 'creates a repository updated event' do
it 'creates a repository updated event when repository exists' do
allow(repository).to receive(:exists?).and_return(true)
expect { subject.execute }.to change(Geo::RepositoryUpdatedEvent, :count).by(1)
end
it 'does not create a repository updated event when repository does not exist' do
allow(repository).to receive(:exists?).and_return(false)
expect { subject.execute }.not_to change(Geo::RepositoryUpdatedEvent, :count)
end
it 'resets the repository verification checksum' do
expect { subject.execute }.to change { repository_state.reload.public_send("#{method_prefix}_verification_checksum") }.to(nil)
end
......@@ -91,9 +99,17 @@ RSpec.describe Geo::RepositoryUpdatedService do
context 'when design repository is being updated' do
let(:repository) { project.design_repository }
it 'creates a design repository updated event' do
it 'creates a design repository updated event when repository exists' do
allow(repository).to receive(:exists?).and_return(true)
expect { subject.execute }.to change(Geo::RepositoryUpdatedEvent, :count).by(1)
end
it 'does not create a repository updated event when repository does not exist' do
allow(repository).to receive(:exists?).and_return(false)
expect { subject.execute }.not_to change(Geo::RepositoryUpdatedEvent, :count)
end
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