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
825b9435
Commit
825b9435
authored
Jul 03, 2018
by
Imre Farkas
Committed by
Nick Thomas
Jul 03, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add readme button to non-empty project page
parent
7054ead4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
67 additions
and
3 deletions
+67
-3
app/presenters/project_presenter.rb
app/presenters/project_presenter.rb
+3
-2
changelogs/unreleased/46963-add_readme_button_for_non_empty_project.yml
...eleased/46963-add_readme_button_for_non_empty_project.yml
+5
-0
spec/features/projects/show/user_sees_setup_shortcut_buttons_spec.rb
...es/projects/show/user_sees_setup_shortcut_buttons_spec.rb
+59
-1
No files found.
app/presenters/project_presenter.rb
View file @
825b9435
...
...
@@ -27,6 +27,7 @@ class ProjectPresenter < Gitlab::View::Presenter::Delegated
def
statistics_buttons
(
show_auto_devops_callout
:)
[
readme_anchor_data
,
changelog_anchor_data
,
license_anchor_data
,
contribution_guide_anchor_data
,
...
...
@@ -212,11 +213,11 @@ class ProjectPresenter < Gitlab::View::Presenter::Delegated
end
def
readme_anchor_data
if
current_user
&&
can_current_user_push_to_default_branch?
&&
repository
.
readme
.
blank
?
if
current_user
&&
can_current_user_push_to_default_branch?
&&
repository
.
readme
.
nil
?
OpenStruct
.
new
(
enabled:
false
,
label:
_
(
'Add Readme'
),
link:
add_readme_path
)
elsif
repository
.
readme
.
present?
elsif
repository
.
readme
OpenStruct
.
new
(
enabled:
true
,
label:
_
(
'Readme'
),
link:
default_view
!=
'readme'
?
readme_path
:
'#readme'
)
...
...
changelogs/unreleased/46963-add_readme_button_for_non_empty_project.yml
0 → 100644
View file @
825b9435
---
title
:
Add readme button to non-empty project page
merge_request
:
20104
author
:
type
:
fixed
spec/features/projects/show/user_sees_setup_shortcut_buttons_spec.rb
View file @
825b9435
...
...
@@ -5,6 +5,8 @@ describe 'Projects > Show > User sees setup shortcut buttons' do
# see spec/features/projects/files/project_owner_creates_license_file_spec.rb
# see spec/features/projects/files/project_owner_sees_link_to_create_license_file_in_empty_project_spec.rb
include
FakeBlobHelpers
let
(
:user
)
{
create
(
:user
)
}
describe
'empty project'
do
...
...
@@ -141,11 +143,57 @@ describe 'Projects > Show > User sees setup shortcut buttons' do
allow_any_instance_of
(
AutoDevopsHelper
).
to
receive
(
:show_auto_devops_callout?
).
and_return
(
false
)
project
.
add_master
(
user
)
sign_in
(
user
)
end
visit
project_path
(
project
)
context
'Readme button'
do
before
do
allow
(
Project
).
to
receive
(
:find_by_full_path
)
.
with
(
project
.
full_path
,
follow_redirects:
true
)
.
and_return
(
project
)
end
context
'when the project has a populated Readme'
do
it
'show the "Readme" anchor'
do
visit
project_path
(
project
)
expect
(
project
.
repository
.
readme
).
not_to
be_nil
page
.
within
(
'.project-stats'
)
do
expect
(
page
).
not_to
have_link
(
'Add Readme'
,
href:
presenter
.
add_readme_path
)
expect
(
page
).
to
have_link
(
'Readme'
,
href:
presenter
.
readme_path
)
end
end
context
'when the project has an empty Readme'
do
it
'show the "Readme" anchor'
do
allow
(
project
.
repository
).
to
receive
(
:readme
).
and_return
(
fake_blob
(
path:
'README.md'
,
data:
''
,
size:
0
))
visit
project_path
(
project
)
page
.
within
(
'.project-stats'
)
do
expect
(
page
).
not_to
have_link
(
'Add Readme'
,
href:
presenter
.
add_readme_path
)
expect
(
page
).
to
have_link
(
'Readme'
,
href:
presenter
.
readme_path
)
end
end
end
end
context
'when the project does not have a Readme'
do
it
'shows the "Add Readme" button'
do
allow
(
project
.
repository
).
to
receive
(
:readme
).
and_return
(
nil
)
visit
project_path
(
project
)
page
.
within
(
'.project-stats'
)
do
expect
(
page
).
to
have_link
(
'Add Readme'
,
href:
presenter
.
add_readme_path
)
end
end
end
end
it
'no "Add Changelog" button if the project already has a changelog'
do
visit
project_path
(
project
)
expect
(
project
.
repository
.
changelog
).
not_to
be_nil
page
.
within
(
'.project-stats'
)
do
...
...
@@ -154,6 +202,8 @@ describe 'Projects > Show > User sees setup shortcut buttons' do
end
it
'no "Add License" button if the project already has a license'
do
visit
project_path
(
project
)
expect
(
project
.
repository
.
license_blob
).
not_to
be_nil
page
.
within
(
'.project-stats'
)
do
...
...
@@ -162,6 +212,8 @@ describe 'Projects > Show > User sees setup shortcut buttons' do
end
it
'no "Add Contribution guide" button if the project already has a contribution guide'
do
visit
project_path
(
project
)
expect
(
project
.
repository
.
contribution_guide
).
not_to
be_nil
page
.
within
(
'.project-stats'
)
do
...
...
@@ -171,6 +223,8 @@ describe 'Projects > Show > User sees setup shortcut buttons' do
describe
'GitLab CI configuration button'
do
it
'"Set up CI/CD" button linked to new file populated for a .gitlab-ci.yml'
do
visit
project_path
(
project
)
expect
(
project
.
repository
.
gitlab_ci_yml
).
to
be_nil
page
.
within
(
'.project-stats'
)
do
...
...
@@ -211,6 +265,8 @@ describe 'Projects > Show > User sees setup shortcut buttons' do
describe
'Auto DevOps button'
do
it
'"Enable Auto DevOps" button linked to settings page'
do
visit
project_path
(
project
)
page
.
within
(
'.project-stats'
)
do
expect
(
page
).
to
have_link
(
'Enable Auto DevOps'
,
href:
project_settings_ci_cd_path
(
project
,
anchor:
'autodevops-settings'
))
end
...
...
@@ -263,6 +319,8 @@ describe 'Projects > Show > User sees setup shortcut buttons' do
describe
'Kubernetes cluster button'
do
it
'"Add Kubernetes cluster" button linked to clusters page'
do
visit
project_path
(
project
)
page
.
within
(
'.project-stats'
)
do
expect
(
page
).
to
have_link
(
'Add Kubernetes cluster'
,
href:
new_project_cluster_path
(
project
))
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