Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
b9c53748
Commit
b9c53748
authored
Jan 20, 2018
by
Stan Hu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix Error 500 when repository has no avatar
Closes #42249
parent
ba02e3a5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
1 deletion
+23
-1
lib/gitlab/git/blob.rb
lib/gitlab/git/blob.rb
+4
-0
spec/controllers/projects/avatars_controller_spec.rb
spec/controllers/projects/avatars_controller_spec.rb
+7
-1
spec/lib/gitlab/git/blob_spec.rb
spec/lib/gitlab/git/blob_spec.rb
+12
-0
No files found.
lib/gitlab/git/blob.rb
View file @
b9c53748
...
...
@@ -132,6 +132,8 @@ module Gitlab
end
def
find_by_gitaly
(
repository
,
sha
,
path
,
limit:
MAX_DATA_DISPLAY_SIZE
)
return
unless
path
path
=
path
.
sub
(
/\A\/*/
,
''
)
path
=
'/'
if
path
.
empty?
name
=
File
.
basename
(
path
)
...
...
@@ -173,6 +175,8 @@ module Gitlab
end
def
find_by_rugged
(
repository
,
sha
,
path
,
limit
:)
return
unless
path
rugged_commit
=
repository
.
lookup
(
sha
)
root_tree
=
rugged_commit
.
tree
...
...
spec/controllers/projects/avatars_controller_spec.rb
View file @
b9c53748
require
'spec_helper'
describe
Projects
::
AvatarsController
do
let
(
:project
)
{
create
(
:project
,
avatar:
fixture_file_upload
(
Rails
.
root
+
"spec/fixtures/dk.png"
,
"image/png"
))
}
let
(
:project
)
{
create
(
:project
,
:repository
,
avatar:
fixture_file_upload
(
Rails
.
root
+
"spec/fixtures/dk.png"
,
"image/png"
))
}
let
(
:user
)
{
create
(
:user
)
}
before
do
...
...
@@ -10,6 +10,12 @@ describe Projects::AvatarsController do
controller
.
instance_variable_set
(
:@project
,
project
)
end
it
'GET #show'
do
get
:show
,
namespace_id:
project
.
namespace
.
id
,
project_id:
project
.
id
expect
(
response
).
to
have_gitlab_http_status
(
404
)
end
it
'removes avatar from DB by calling destroy'
do
delete
:destroy
,
namespace_id:
project
.
namespace
.
id
,
project_id:
project
.
id
expect
(
project
.
avatar
.
present?
).
to
be_falsey
...
...
spec/lib/gitlab/git/blob_spec.rb
View file @
b9c53748
...
...
@@ -16,6 +16,18 @@ describe Gitlab::Git::Blob, seed_helper: true do
end
shared_examples
'finding blobs'
do
context
'nil path'
do
let
(
:blob
)
{
Gitlab
::
Git
::
Blob
.
find
(
repository
,
SeedRepo
::
Commit
::
ID
,
nil
)
}
it
{
expect
(
blob
).
to
eq
(
nil
)
}
end
context
'blank path'
do
let
(
:blob
)
{
Gitlab
::
Git
::
Blob
.
find
(
repository
,
SeedRepo
::
Commit
::
ID
,
''
)
}
it
{
expect
(
blob
).
to
eq
(
nil
)
}
end
context
'file in subdir'
do
let
(
:blob
)
{
Gitlab
::
Git
::
Blob
.
find
(
repository
,
SeedRepo
::
Commit
::
ID
,
"files/ruby/popen.rb"
)
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment