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
Boxiang Sun
gitlab-ce
Commits
d195db17
Commit
d195db17
authored
Jul 06, 2017
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't show auxiliary blob viewer for README when there is no wiki
parent
bb918a2f
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
64 additions
and
1 deletion
+64
-1
app/models/blob_viewer/readme.rb
app/models/blob_viewer/readme.rb
+6
-0
app/models/project_wiki.rb
app/models/project_wiki.rb
+4
-0
app/views/projects/blob/viewers/_readme.html.haml
app/views/projects/blob/viewers/_readme.html.haml
+1
-1
changelogs/unreleased/dm-readme-auxiliary-blob-viewer-without-wiki.yml
...released/dm-readme-auxiliary-blob-viewer-without-wiki.yml
+4
-0
spec/models/blob_viewer/readme_spec.rb
spec/models/blob_viewer/readme_spec.rb
+49
-0
No files found.
app/models/blob_viewer/readme.rb
View file @
d195db17
...
@@ -10,5 +10,11 @@ module BlobViewer
...
@@ -10,5 +10,11 @@ module BlobViewer
def
visible_to?
(
current_user
)
def
visible_to?
(
current_user
)
can?
(
current_user
,
:read_wiki
,
project
)
can?
(
current_user
,
:read_wiki
,
project
)
end
end
def
render_error
return
if
project
.
has_external_wiki?
||
(
project
.
wiki_enabled?
&&
project
.
wiki
.
has_home_page?
)
:no_wiki
end
end
end
end
end
app/models/project_wiki.rb
View file @
d195db17
...
@@ -63,6 +63,10 @@ class ProjectWiki
...
@@ -63,6 +63,10 @@ class ProjectWiki
!!
repository
.
exists?
!!
repository
.
exists?
end
end
def
has_home_page?
!!
find_page
(
'home'
)
end
# Returns an Array of Gitlab WikiPage instances or an
# Returns an Array of Gitlab WikiPage instances or an
# empty Array if this Wiki has no pages.
# empty Array if this Wiki has no pages.
def
pages
def
pages
...
...
app/views/projects/blob/viewers/_readme.html.haml
View file @
d195db17
=
icon
(
'info-circle fw'
)
=
icon
(
'info-circle fw'
)
=
succeed
'.'
do
=
succeed
'.'
do
To learn more about this project, read
To learn more about this project, read
=
link_to
"the wiki"
,
project_wikis
_path
(
viewer
.
project
)
=
link_to
"the wiki"
,
get_project_wiki
_path
(
viewer
.
project
)
changelogs/unreleased/dm-readme-auxiliary-blob-viewer-without-wiki.yml
0 → 100644
View file @
d195db17
---
title
:
Don't show auxiliary blob viewer for README when there is no wiki
merge_request
:
author
:
spec/models/blob_viewer/readme_spec.rb
0 → 100644
View file @
d195db17
require
'spec_helper'
describe
BlobViewer
::
Readme
,
model:
true
do
include
FakeBlobHelpers
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:blob
)
{
fake_blob
(
path:
'README.md'
)
}
subject
{
described_class
.
new
(
blob
)
}
describe
'#render_error'
do
context
'when there is no wiki'
do
it
'returns :no_wiki'
do
expect
(
subject
.
render_error
).
to
eq
(
:no_wiki
)
end
end
context
'when there is an external wiki'
do
before
do
project
.
has_external_wiki
=
true
end
it
'returns nil'
do
expect
(
subject
.
render_error
).
to
be_nil
end
end
context
'when there is a local wiki'
do
before
do
project
.
wiki_enabled
=
true
end
context
'when the wiki is empty'
do
it
'returns :no_wiki'
do
expect
(
subject
.
render_error
).
to
eq
(
:no_wiki
)
end
end
context
'when the wiki is not empty'
do
before
do
WikiPages
::
CreateService
.
new
(
project
,
project
.
owner
,
title:
'home'
,
content:
'Home page'
).
execute
end
it
'returns nil'
do
expect
(
subject
.
render_error
).
to
be_nil
end
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