diff options
author | Stan Hu <stanhu@gmail.com> | 2016-03-24 09:29:00 -0700 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2016-03-25 06:30:51 -0700 |
commit | 506878970b2040be7446fc1a341d7abc61f9c6ec (patch) | |
tree | c1f1693ce133afa20ebc06c26c18ed1ae26c9900 /spec | |
parent | 63c8a05bf7f18ac4093ece1f08b4b5fd8dba5fac (diff) | |
download | gitlab-ce-506878970b2040be7446fc1a341d7abc61f9c6ec.tar.gz |
Don't attempt to look up an avatar in repo if repo directory does not exist
Closes #14580
Diffstat (limited to 'spec')
-rw-r--r-- | spec/models/project_spec.rb | 6 | ||||
-rw-r--r-- | spec/models/repository_spec.rb | 6 |
2 files changed, 12 insertions, 0 deletions
diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index 20f06f4b7e1..55f1c665b86 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -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 diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb index 7eac70ae948..b30a6e7ae3d 100644 --- a/spec/models/repository_spec.rb +++ b/spec/models/repository_spec.rb @@ -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'). |