Don't attempt to look up an avatar in repo if repo directory does not exist
Closes #14580
This commit is contained in:
parent
63c8a05bf7
commit
506878970b
|
@ -1,6 +1,7 @@
|
||||||
Please view this file on the master branch, on stable branches it's out of date.
|
Please view this file on the master branch, on stable branches it's out of date.
|
||||||
|
|
||||||
v 8.7.0 (unreleased)
|
v 8.7.0 (unreleased)
|
||||||
|
- Don't attempt to look up an avatar in repo if repo directory does not exist (Stan hu)
|
||||||
- Preserve time notes/comments have been updated at when moving issue
|
- Preserve time notes/comments have been updated at when moving issue
|
||||||
- Make HTTP(s) label consistent on clone bar (Stan Hu)
|
- Make HTTP(s) label consistent on clone bar (Stan Hu)
|
||||||
- Fix avatar stretching by providing a cropping feature
|
- Fix avatar stretching by providing a cropping feature
|
||||||
|
|
|
@ -877,6 +877,8 @@ class Repository
|
||||||
end
|
end
|
||||||
|
|
||||||
def avatar
|
def avatar
|
||||||
|
return nil unless exists?
|
||||||
|
|
||||||
@avatar ||= cache.fetch(:avatar) do
|
@avatar ||= cache.fetch(:avatar) do
|
||||||
AVATAR_FILES.find do |file|
|
AVATAR_FILES.find do |file|
|
||||||
blob_at_branch('master', file)
|
blob_at_branch('master', file)
|
||||||
|
|
|
@ -422,6 +422,12 @@ describe Project, models: true do
|
||||||
|
|
||||||
it { should eq "http://localhost#{avatar_path}" }
|
it { should eq "http://localhost#{avatar_path}" }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'when git repo is empty' do
|
||||||
|
let(:project) { create(:empty_project) }
|
||||||
|
|
||||||
|
it { should eq nil }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe :ci_commit do
|
describe :ci_commit do
|
||||||
|
|
|
@ -725,6 +725,12 @@ describe Repository, models: true do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#avatar' do
|
describe '#avatar' do
|
||||||
|
it 'returns nil if repo does not exist' do
|
||||||
|
expect(repository).to receive(:exists?).and_return(false)
|
||||||
|
|
||||||
|
expect(repository.avatar).to eq(nil)
|
||||||
|
end
|
||||||
|
|
||||||
it 'returns the first avatar file found in the repository' do
|
it 'returns the first avatar file found in the repository' do
|
||||||
expect(repository).to receive(:blob_at_branch).
|
expect(repository).to receive(:blob_at_branch).
|
||||||
with('master', 'logo.png').
|
with('master', 'logo.png').
|
||||||
|
|
Loading…
Reference in New Issue