Commit 5b6d347f authored by Yorick Peterse's avatar Yorick Peterse

Handle raw_repository returning nil in exists?

If path_with_namespace is nil Repository#raw_repository will also return
nil. Apparently code out there creates a Repository instance without a
namespace path. Right.
parent 19b21c2e
...@@ -38,6 +38,8 @@ class Repository ...@@ -38,6 +38,8 @@ class Repository
end end
def exists? def exists?
return false unless raw_repository
raw_repository.rugged raw_repository.rugged
true true
rescue Gitlab::Git::Repository::NoRepository rescue Gitlab::Git::Repository::NoRepository
......
...@@ -240,6 +240,12 @@ describe Repository, models: true do ...@@ -240,6 +240,12 @@ describe Repository, models: true do
expect(repository.exists?).to eq(false) expect(repository.exists?).to eq(false)
end end
it 'returns false when there is no namespace' do
allow(repository).to receive(:path_with_namespace).and_return(nil)
expect(repository.exists?).to eq(false)
end
end end
describe '#has_visible_content?' do describe '#has_visible_content?' do
......
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