Commit 7d629787 authored by Gabriel Mazetto's avatar Gabriel Mazetto

Add `wiki` extra namespace when repository is_wiki: true

parent 2123b789
......@@ -1049,11 +1049,19 @@ class Repository
end
def cache
@cache ||= Gitlab::RepositoryCache.new(self)
@cache ||= if is_wiki
Gitlab::RepositoryCache.new(self, extra_namespace: 'wiki')
else
Gitlab::RepositoryCache.new(self)
end
end
def request_store_cache
@request_store_cache ||= Gitlab::RepositoryCache.new(self, backend: Gitlab::SafeRequestStore)
@request_store_cache ||= if is_wiki
Gitlab::RepositoryCache.new(self, extra_namespace: 'wiki', backend: Gitlab::SafeRequestStore)
else
Gitlab::RepositoryCache.new(self, backend: Gitlab::SafeRequestStore)
end
end
def tags_sorted_by_committed_date
......
......@@ -2403,4 +2403,22 @@ describe Repository do
repository.merge_base('master', 'fix')
end
end
describe '#cache' do
subject(:cache) { repository.send(:cache) }
it 'returns a RepositoryCache' do
expect(subject).to be_kind_of Gitlab::RepositoryCache
end
it 'when is_wiki it includes wiki as part of key' do
allow(repository).to receive(:is_wiki) { true }
expect(subject.namespace).to include('wiki')
end
it 'when is_wiki is false extra_namespace is nil' do
expect(subject.namespace).not_to include('wiki')
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