summaryrefslogtreecommitdiff
path: root/spec/models
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2016-03-27 00:21:57 +0000
committerStan Hu <stanhu@gmail.com>2016-03-27 00:21:57 +0000
commitc1834664a7a29a32551291102265ece978c55ffe (patch)
treea884cce1fb71d495debc0c0371604be6df88bc69 /spec/models
parent8034e1a154aa355b8a212cc48acddf0401d414ce (diff)
parent506878970b2040be7446fc1a341d7abc61f9c6ec (diff)
downloadgitlab-ce-c1834664a7a29a32551291102265ece978c55ffe.tar.gz
Merge branch 'handle-avatar-in-empty-repo' into 'master'
Don't attempt to look up an avatar in repo if repo directory does not exist Relates to https://sentry.gitlap.com/gitlab/gitlabcom/issues/3507/ Closes #14580 See merge request !3390
Diffstat (limited to 'spec/models')
-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 417f11acca4..f10d671104c 100644
--- a/spec/models/repository_spec.rb
+++ b/spec/models/repository_spec.rb
@@ -744,6 +744,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').