Fix Geo::DeletedProject#path_with_namespace

parent 7f605d07
class Geo::DeletedProject < ::Project class Geo::DeletedProject < ::Project
after_initialize :readonly! after_initialize :readonly!
attr_reader :full_path
def initialize(id:, name:, full_path:, repository_storage:) def initialize(id:, name:, full_path:, repository_storage:)
repository_storage ||= current_application_settings.pick_repository_storage repository_storage ||= current_application_settings.pick_repository_storage
...@@ -9,7 +8,8 @@ class Geo::DeletedProject < ::Project ...@@ -9,7 +8,8 @@ class Geo::DeletedProject < ::Project
@full_path = full_path @full_path = full_path
end end
def repository def full_path
@repository ||= Repository.new(full_path, self) @full_path
end end
alias_method :path_with_namespace, :full_path
end end
...@@ -28,6 +28,12 @@ module EE ...@@ -28,6 +28,12 @@ module EE
remove_tracking_entries! remove_tracking_entries!
log_info("Project \"#{project.name}\" was removed") log_info("Project \"#{project.name}\" was removed")
end end
def remove_tracking_entries!
return unless Gitlab::Geo.secondary?
Geo::ProjectRegistry.where(project_id: project.id).delete_all
end
end end
end end
end end
...@@ -103,12 +103,6 @@ module Projects ...@@ -103,12 +103,6 @@ module Projects
end end
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) def raise_error(message)
raise DestroyError.new(message) raise DestroyError.new(message)
end end
......
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