summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2016-03-24 09:29:00 -0700
committerStan Hu <stanhu@gmail.com>2016-03-25 06:30:51 -0700
commit506878970b2040be7446fc1a341d7abc61f9c6ec (patch)
treec1f1693ce133afa20ebc06c26c18ed1ae26c9900 /spec
parent63c8a05bf7f18ac4093ece1f08b4b5fd8dba5fac (diff)
downloadgitlab-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.rb6
-rw-r--r--spec/models/repository_spec.rb6
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').