Don't attempt to look up an avatar in repo if repo directory does not exist

Closes #14580
This commit is contained in:
Stan Hu 2016-03-24 09:29:00 -07:00
parent 63c8a05bf7
commit 506878970b
4 changed files with 15 additions and 0 deletions

View file

@ -1,6 +1,7 @@
Please view this file on the master branch, on stable branches it's out of date.
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
- Make HTTP(s) label consistent on clone bar (Stan Hu)
- Fix avatar stretching by providing a cropping feature

View file

@ -877,6 +877,8 @@ class Repository
end
def avatar
return nil unless exists?
@avatar ||= cache.fetch(:avatar) do
AVATAR_FILES.find do |file|
blob_at_branch('master', file)

View file

@ -422,6 +422,12 @@ describe Project, models: true do
it { should eq "http://localhost#{avatar_path}" }
end
context 'when git repo is empty' do
let(:project) { create(:empty_project) }
it { should eq nil }
end
end
describe :ci_commit do

View file

@ -725,6 +725,12 @@ describe Repository, models: true do
end
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
expect(repository).to receive(:blob_at_branch).
with('master', 'logo.png').