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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
0527ea09
Commit
0527ea09
authored
Nov 08, 2016
by
tiagonbotelho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adds guard clause for readme model method and initializes a new view with proper stylesheets
parent
6eeff67c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
1 deletion
+30
-1
app/helpers/preferences_helper.rb
app/helpers/preferences_helper.rb
+3
-1
app/models/repository.rb
app/models/repository.rb
+2
-0
changelogs/unreleased/23990-project-show-error-when-empty-repo.yml
...s/unreleased/23990-project-show-error-when-empty-repo.yml
+4
-0
spec/helpers/preferences_helper_spec.rb
spec/helpers/preferences_helper_spec.rb
+21
-0
No files found.
app/helpers/preferences_helper.rb
View file @
0527ea09
...
...
@@ -50,7 +50,9 @@ module PreferencesHelper
end
def
default_project_view
return
'readme'
unless
current_user
unless
current_user
return
@repository
.
head_commit
?
'readme'
:
'activity'
end
user_view
=
current_user
.
project_view
...
...
app/models/repository.rb
View file @
0527ea09
...
...
@@ -554,6 +554,8 @@ class Repository
end
def
readme
return
unless
head_commit
cache
.
fetch
(
:readme
)
{
tree
(
:head
).
readme
}
end
...
...
changelogs/unreleased/23990-project-show-error-when-empty-repo.yml
0 → 100644
View file @
0527ea09
---
title
:
500 error on project show when user is not logged in and project is still empty
merge_request
:
7376
author
:
spec/helpers/preferences_helper_spec.rb
View file @
0527ea09
...
...
@@ -85,4 +85,25 @@ describe PreferencesHelper do
and_return
(
double
(
'user'
,
messages
))
end
end
describe
'default_project_view'
do
let
(
:project
)
{
create
(
:project
)
}
context
'user not signed in'
do
before
do
stub_user
@repository
=
project
.
repository
end
it
'returns readme view if repository is not empty'
do
expect
(
helper
.
default_project_view
).
to
eq
(
'readme'
)
end
it
'returns activity if repository is empty'
do
expect
(
@repository
).
to
receive
(
:head_commit
).
and_return
(
nil
)
expect
(
helper
.
default_project_view
).
to
eq
(
'activity'
)
end
end
end
end
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