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.
This commit is contained in:
parent
19b21c2e0c
commit
5b6d347fcd
2 changed files with 8 additions and 0 deletions
|
@ -38,6 +38,8 @@ class Repository
|
|||
end
|
||||
|
||||
def exists?
|
||||
return false unless raw_repository
|
||||
|
||||
raw_repository.rugged
|
||||
true
|
||||
rescue Gitlab::Git::Repository::NoRepository
|
||||
|
|
|
@ -240,6 +240,12 @@ describe Repository, models: true do
|
|||
|
||||
expect(repository.exists?).to eq(false)
|
||||
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
|
||||
|
||||
describe '#has_visible_content?' do
|
||||
|
|
Loading…
Reference in a new issue