Expires full_path cache after project is renamed

parent 37011af0
......@@ -103,8 +103,11 @@ module Routable
def full_path
return uncached_full_path unless RequestStore.active?
key = "routable/full_path/#{self.class.name}/#{self.id}"
RequestStore[key] ||= uncached_full_path
RequestStore[full_path_key] ||= uncached_full_path
end
def expires_full_path_cache
RequestStore.delete(full_path_key) if RequestStore.active?
end
def build_full_path
......@@ -135,6 +138,10 @@ module Routable
path_changed? || parent_changed?
end
def full_path_key
@full_path_key ||= "routable/full_path/#{self.class.name}/#{self.id}"
end
def build_full_name
if parent && name
parent.human_name + ' / ' + name
......
......@@ -963,6 +963,7 @@ class Project < ActiveRecord::Base
begin
gitlab_shell.mv_repository(repository_storage_path, "#{old_path_with_namespace}.wiki", "#{new_path_with_namespace}.wiki")
send_move_instructions(old_path_with_namespace)
expires_full_path_cache
@old_path_with_namespace = old_path_with_namespace
......
......@@ -132,6 +132,18 @@ describe Group, 'Routable' do
end
end
describe '#expires_full_path_cache' do
context 'with RequestStore active', :request_store do
it 'expires the full_path cache' do
expect(group).to receive(:uncached_full_path).twice.and_call_original
3.times { group.full_path }
group.expires_full_path_cache
3.times { group.full_path }
end
end
end
describe '#full_name' do
let(:group) { create(:group) }
let(:nested_group) { create(:group, parent: group) }
......
......@@ -1216,6 +1216,8 @@ describe Project, models: true do
expect(project).to receive(:expire_caches_before_rename)
expect(project).to receive(:expires_full_path_cache)
project.rename_repo
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