Commit aa29e639 authored by Douwe Maan's avatar Douwe Maan

Merge branch 'fix-2726' into 'master'

Geo - Fix path_with_namespace for instances of Geo::DeletedProject

Closes #2726

See merge request !2267
parents 8b2b0641 aace2bed
class Geo::DeletedProject < ::Project
after_initialize :readonly!
attr_reader :full_path
def initialize(id:, name:, full_path:, repository_storage:)
repository_storage ||= current_application_settings.pick_repository_storage
......@@ -9,7 +8,8 @@ class Geo::DeletedProject < ::Project
@full_path = full_path
end
def repository
@repository ||= Repository.new(full_path, self)
def full_path
@full_path
end
alias_method :path_with_namespace, :full_path
end
......@@ -28,6 +28,12 @@ module EE
remove_tracking_entries!
log_info("Project \"#{project.name}\" was removed")
end
def remove_tracking_entries!
return unless ::Gitlab::Geo.secondary?
::Geo::ProjectRegistry.where(project_id: project.id).delete_all
end
end
end
end
......@@ -103,12 +103,6 @@ module Projects
end
end
def remove_tracking_entries!
return unless Gitlab::Geo.secondary?
Geo::ProjectRegistry.where(project_id: project.id).delete_all
end
def raise_error(message)
raise DestroyError.new(message)
end
......
---
title: Geo - Fix path_with_namespace for instances of Geo::DeletedProject
merge_request:
author:
require 'spec_helper'
RSpec.describe Geo::DeletedProject, type: :model do
subject { described_class.new(id: 1, name: 'sample', full_path: 'root/sample', repository_storage: nil) }
it { expect(subject).to be_kind_of(Project) }
describe '#full_path' do
it 'returns the initialized value' do
expect(subject.full_path).to eq 'root/sample'
end
end
describe '#path_with_namespace' do
it 'is an alias for full_path' do
full_path = described_class.instance_method(:full_path)
path_with_namespace = described_class.instance_method(:path_with_namespace)
expect(path_with_namespace).to eq(full_path)
end
end
describe '#repository' do
it 'returns a valid repository' do
expect(subject.repository).to be_kind_of(Repository)
expect(subject.repository.path_with_namespace).to eq('root/sample')
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