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
95ea8bdf
Commit
95ea8bdf
authored
Oct 14, 2020
by
Alex Kalderimis
Committed by
Kerri Miller
Oct 14, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update feature and presenter specs
Update projects spec
parent
a355b01a
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
117 additions
and
22 deletions
+117
-22
app/presenters/project_presenter.rb
app/presenters/project_presenter.rb
+11
-7
changelogs/unreleased/copy-project-homepage-default-view-for-anonoymous-users.yml
...py-project-homepage-default-view-for-anonoymous-users.yml
+5
-0
spec/controllers/projects_controller_spec.rb
spec/controllers/projects_controller_spec.rb
+2
-2
spec/features/projects/features_visibility_spec.rb
spec/features/projects/features_visibility_spec.rb
+1
-1
spec/features/projects/user_sees_sidebar_spec.rb
spec/features/projects/user_sees_sidebar_spec.rb
+56
-3
spec/presenters/project_presenter_spec.rb
spec/presenters/project_presenter_spec.rb
+42
-9
No files found.
app/presenters/project_presenter.rb
View file @
95ea8bdf
...
@@ -65,14 +65,14 @@ class ProjectPresenter < Gitlab::View::Presenter::Delegated
...
@@ -65,14 +65,14 @@ class ProjectPresenter < Gitlab::View::Presenter::Delegated
if
can?
(
current_user
,
:download_code
,
project
)
if
can?
(
current_user
,
:download_code
,
project
)
user_view
user_view
elsif
user_view
==
"activity"
elsif
user_view
==
'activity'
"activity"
'activity'
elsif
can?
(
current_user
,
:read_wiki
,
project
)
elsif
project
.
wiki_repository_exists?
&&
can?
(
current_user
,
:read_wiki
,
project
)
"wiki"
'wiki'
elsif
feature_available?
(
:issues
,
current_user
)
elsif
can?
(
current_user
,
:read_issue
,
project
)
"projects/issues/issues"
'projects/issues/issues'
else
else
"customize_workflow"
'activity'
end
end
end
end
...
@@ -389,6 +389,10 @@ class ProjectPresenter < Gitlab::View::Presenter::Delegated
...
@@ -389,6 +389,10 @@ class ProjectPresenter < Gitlab::View::Presenter::Delegated
def
anonymous_project_view
def
anonymous_project_view
if
!
project
.
empty_repo?
&&
can?
(
current_user
,
:download_code
,
project
)
if
!
project
.
empty_repo?
&&
can?
(
current_user
,
:download_code
,
project
)
'files'
'files'
elsif
project
.
wiki_repository_exists?
&&
can?
(
current_user
,
:read_wiki
,
project
)
'wiki'
elsif
can?
(
current_user
,
:read_issue
,
project
)
'projects/issues/issues'
else
else
'activity'
'activity'
end
end
...
...
changelogs/unreleased/copy-project-homepage-default-view-for-anonoymous-users.yml
0 → 100644
View file @
95ea8bdf
---
title
:
Copy project homepage default view for anonymous users
merge_request
:
44606
author
:
George Tsiolis
type
:
changed
spec/controllers/projects_controller_spec.rb
View file @
95ea8bdf
...
@@ -213,13 +213,13 @@ RSpec.describe ProjectsController do
...
@@ -213,13 +213,13 @@ RSpec.describe ProjectsController do
expect
(
assigns
(
:issuable_meta_data
)).
not_to
be_nil
expect
(
assigns
(
:issuable_meta_data
)).
not_to
be_nil
end
end
it
'shows
customize workflow
page if wiki and issues are disabled'
do
it
'shows
activity
page if wiki and issues are disabled'
do
project
.
project_feature
.
update_attribute
(
:wiki_access_level
,
ProjectFeature
::
DISABLED
)
project
.
project_feature
.
update_attribute
(
:wiki_access_level
,
ProjectFeature
::
DISABLED
)
project
.
project_feature
.
update_attribute
(
:issues_access_level
,
ProjectFeature
::
DISABLED
)
project
.
project_feature
.
update_attribute
(
:issues_access_level
,
ProjectFeature
::
DISABLED
)
get
:show
,
params:
{
namespace_id:
project
.
namespace
,
id:
project
}
get
:show
,
params:
{
namespace_id:
project
.
namespace
,
id:
project
}
expect
(
response
).
to
render_template
(
"projects/_
customize_workflow
"
)
expect
(
response
).
to
render_template
(
"projects/_
activity
"
)
end
end
it
'shows activity if enabled by user'
do
it
'shows activity if enabled by user'
do
...
...
spec/features/projects/features_visibility_spec.rb
View file @
95ea8bdf
...
@@ -201,7 +201,7 @@ RSpec.describe 'Edit Project Settings' do
...
@@ -201,7 +201,7 @@ RSpec.describe 'Edit Project Settings' do
visit
project_path
(
project
)
visit
project_path
(
project
)
expect
(
page
).
to
have_content
"
Customize your workflow!
"
expect
(
page
).
to
have_content
"
joined project
"
end
end
it
"hides project activity tabs"
do
it
"hides project activity tabs"
do
...
...
spec/features/projects/user_sees_sidebar_spec.rb
View file @
95ea8bdf
...
@@ -128,6 +128,59 @@ RSpec.describe 'Projects > User sees sidebar' do
...
@@ -128,6 +128,59 @@ RSpec.describe 'Projects > User sees sidebar' do
end
end
end
end
context
'as anonymous'
do
let
(
:project
)
{
create
(
:project
,
:public
)
}
let!
(
:issue
)
{
create
(
:issue
,
:opened
,
project:
project
,
author:
user
)
}
describe
'project landing page'
do
before
do
project
.
project_feature
.
update!
(
builds_access_level:
ProjectFeature
::
DISABLED
,
merge_requests_access_level:
ProjectFeature
::
DISABLED
,
repository_access_level:
ProjectFeature
::
DISABLED
,
issues_access_level:
ProjectFeature
::
DISABLED
,
wiki_access_level:
ProjectFeature
::
DISABLED
)
end
it
'does not show the project file list landing page, but the activity'
do
visit
project_path
(
project
)
expect
(
page
).
not_to
have_selector
'.project-stats'
expect
(
page
).
not_to
have_selector
'.project-last-commit'
expect
(
page
).
not_to
have_selector
'.project-show-files'
expect
(
page
).
to
have_selector
'.project-show-activity'
end
it
'shows the wiki when enabled'
do
project
.
project_feature
.
update!
(
wiki_access_level:
ProjectFeature
::
ENABLED
)
visit
project_path
(
project
)
expect
(
page
).
to
have_selector
'.project-show-wiki'
end
it
'shows the issues when enabled'
do
project
.
project_feature
.
update!
(
issues_access_level:
ProjectFeature
::
ENABLED
)
visit
project_path
(
project
)
expect
(
page
).
to
have_selector
'.issues-list'
end
it
'shows the wiki when wiki and issues are enabled'
do
project
.
project_feature
.
update!
(
issues_access_level:
ProjectFeature
::
ENABLED
,
wiki_access_level:
ProjectFeature
::
ENABLED
)
visit
project_path
(
project
)
expect
(
page
).
to
have_selector
'.project-show-wiki'
end
end
end
context
'as guest'
do
context
'as guest'
do
let
(
:guest
)
{
create
(
:user
)
}
let
(
:guest
)
{
create
(
:user
)
}
let!
(
:issue
)
{
create
(
:issue
,
:opened
,
project:
project
,
author:
guest
)
}
let!
(
:issue
)
{
create
(
:issue
,
:opened
,
project:
project
,
author:
guest
)
}
...
@@ -194,13 +247,13 @@ RSpec.describe 'Projects > User sees sidebar' do
...
@@ -194,13 +247,13 @@ RSpec.describe 'Projects > User sees sidebar' do
expect
(
page
).
not_to
have_selector
'.project-stats'
expect
(
page
).
not_to
have_selector
'.project-stats'
expect
(
page
).
not_to
have_selector
'.project-last-commit'
expect
(
page
).
not_to
have_selector
'.project-last-commit'
expect
(
page
).
not_to
have_selector
'.project-show-files'
expect
(
page
).
not_to
have_selector
'.project-show-files'
expect
(
page
).
to
have_selector
'.project-show-
customize_workflow
'
expect
(
page
).
to
have_selector
'.project-show-
activity
'
end
end
it
'shows the
customize workflow
when issues and wiki are disabled'
do
it
'shows the
project activity
when issues and wiki are disabled'
do
visit
project_path
(
project
)
visit
project_path
(
project
)
expect
(
page
).
to
have_selector
'.project-show-
customize_workflow
'
expect
(
page
).
to
have_selector
'.project-show-
activity
'
end
end
it
'shows the wiki when enabled'
do
it
'shows the wiki when enabled'
do
...
...
spec/presenters/project_presenter_spec.rb
View file @
95ea8bdf
...
@@ -38,14 +38,33 @@ RSpec.describe ProjectPresenter do
...
@@ -38,14 +38,33 @@ RSpec.describe ProjectPresenter do
context
'when repository is empty'
do
context
'when repository is empty'
do
let_it_be
(
:project
)
{
create
(
:project_empty_repo
,
:public
)
}
let_it_be
(
:project
)
{
create
(
:project_empty_repo
,
:public
)
}
it
'returns activity if user has repository access'
do
it
'returns wiki if user has repository access and can read wiki, which exists'
do
allow
(
project
).
to
receive
(
:wiki_repository_exists?
).
and_return
(
true
)
allow
(
presenter
).
to
receive
(
:can?
).
with
(
nil
,
:download_code
,
project
).
and_return
(
true
)
allow
(
presenter
).
to
receive
(
:can?
).
with
(
nil
,
:download_code
,
project
).
and_return
(
true
)
allow
(
presenter
).
to
receive
(
:can?
).
with
(
nil
,
:read_wiki
,
project
).
and_return
(
true
)
allow
(
presenter
).
to
receive
(
:can?
).
with
(
nil
,
:read_issue
,
project
).
and_return
(
false
)
expect
(
presenter
.
default_view
).
to
eq
(
'wiki'
)
end
it
'returns activity if user has repository access and can read wiki, which does not exist'
do
allow
(
presenter
).
to
receive
(
:can?
).
with
(
nil
,
:download_code
,
project
).
and_return
(
true
)
allow
(
presenter
).
to
receive
(
:can?
).
with
(
nil
,
:read_wiki
,
project
).
and_return
(
true
)
allow
(
presenter
).
to
receive
(
:can?
).
with
(
nil
,
:read_issue
,
project
).
and_return
(
false
)
expect
(
presenter
.
default_view
).
to
eq
(
'activity'
)
expect
(
presenter
.
default_view
).
to
eq
(
'activity'
)
end
end
it
'returns activity if user does not have repository access'
do
it
'returns issues if user does not have repository access, but can read issues'
do
allow
(
project
).
to
receive
(
:can?
).
with
(
nil
,
:download_code
,
project
).
and_return
(
false
)
allow
(
presenter
).
to
receive
(
:can?
).
with
(
nil
,
:download_code
,
project
).
and_return
(
false
)
allow
(
presenter
).
to
receive
(
:can?
).
with
(
nil
,
:read_issue
,
project
).
and_call_original
expect
(
presenter
.
default_view
).
to
eq
(
'projects/issues/issues'
)
end
it
'returns activity if user can read neither wiki nor issues'
do
allow
(
presenter
).
to
receive
(
:can?
).
with
(
nil
,
:download_code
,
project
).
and_return
(
false
)
allow
(
presenter
).
to
receive
(
:can?
).
with
(
nil
,
:read_issue
,
project
).
and_return
(
false
)
expect
(
presenter
.
default_view
).
to
eq
(
'activity'
)
expect
(
presenter
.
default_view
).
to
eq
(
'activity'
)
end
end
...
@@ -61,8 +80,18 @@ RSpec.describe ProjectPresenter do
...
@@ -61,8 +80,18 @@ RSpec.describe ProjectPresenter do
expect
(
presenter
.
default_view
).
to
eq
(
'files'
)
expect
(
presenter
.
default_view
).
to
eq
(
'files'
)
end
end
it
'returns activity if user does not have repository access'
do
it
'returns wiki if user does not have repository access and can read wiki, which exists'
do
allow
(
project
).
to
receive
(
:wiki_repository_exists?
).
and_return
(
true
)
allow
(
presenter
).
to
receive
(
:can?
).
with
(
nil
,
:download_code
,
project
).
and_return
(
false
)
allow
(
presenter
).
to
receive
(
:can?
).
with
(
nil
,
:download_code
,
project
).
and_return
(
false
)
allow
(
presenter
).
to
receive
(
:can?
).
with
(
nil
,
:read_wiki
,
project
).
and_return
(
true
)
expect
(
presenter
.
default_view
).
to
eq
(
'wiki'
)
end
it
'returns activity if user does not have repository or wiki access'
do
allow
(
presenter
).
to
receive
(
:can?
).
with
(
nil
,
:download_code
,
project
).
and_return
(
false
)
allow
(
presenter
).
to
receive
(
:can?
).
with
(
nil
,
:read_issue
,
project
).
and_return
(
false
)
allow
(
presenter
).
to
receive
(
:can?
).
with
(
nil
,
:read_wiki
,
project
).
and_return
(
false
)
expect
(
presenter
.
default_view
).
to
eq
(
'activity'
)
expect
(
presenter
.
default_view
).
to
eq
(
'activity'
)
end
end
...
@@ -96,22 +125,25 @@ RSpec.describe ProjectPresenter do
...
@@ -96,22 +125,25 @@ RSpec.describe ProjectPresenter do
allow
(
presenter
).
to
receive
(
:can?
).
with
(
user
,
:download_code
,
project
).
and_return
(
false
)
allow
(
presenter
).
to
receive
(
:can?
).
with
(
user
,
:download_code
,
project
).
and_return
(
false
)
end
end
it
'returns wiki if the user has the right policy'
do
it
'returns wiki if the user has the right policy and the wiki exists'
do
allow
(
project
).
to
receive
(
:wiki_repository_exists?
).
and_return
(
true
)
allow
(
presenter
).
to
receive
(
:can?
).
with
(
user
,
:read_wiki
,
project
).
and_return
(
true
)
allow
(
presenter
).
to
receive
(
:can?
).
with
(
user
,
:read_wiki
,
project
).
and_return
(
true
)
expect
(
presenter
.
default_view
).
to
eq
(
'wiki'
)
expect
(
presenter
.
default_view
).
to
eq
(
'wiki'
)
end
end
it
'returns
customize_workflow
if the user does not have the right policy'
do
it
'returns
activity
if the user does not have the right policy'
do
allow
(
presenter
).
to
receive
(
:can?
).
with
(
user
,
:read_wiki
,
project
).
and_return
(
false
)
allow
(
presenter
).
to
receive
(
:can?
).
with
(
user
,
:read_wiki
,
project
).
and_return
(
false
)
allow
(
presenter
).
to
receive
(
:can?
).
with
(
user
,
:read_issue
,
project
).
and_return
(
false
)
expect
(
presenter
.
default_view
).
to
eq
(
'
customize_workflow
'
)
expect
(
presenter
.
default_view
).
to
eq
(
'
activity
'
)
end
end
end
end
context
'with issues as a feature available'
do
context
'with issues as a feature available'
do
it
'return issues'
do
it
'return issues'
do
allow
(
presenter
).
to
receive
(
:can?
).
with
(
user
,
:download_code
,
project
).
and_return
(
false
)
allow
(
presenter
).
to
receive
(
:can?
).
with
(
user
,
:download_code
,
project
).
and_return
(
false
)
allow
(
presenter
).
to
receive
(
:can?
).
with
(
user
,
:read_issue
,
project
).
and_return
(
true
)
allow
(
presenter
).
to
receive
(
:can?
).
with
(
user
,
:read_wiki
,
project
).
and_return
(
false
)
allow
(
presenter
).
to
receive
(
:can?
).
with
(
user
,
:read_wiki
,
project
).
and_return
(
false
)
expect
(
presenter
.
default_view
).
to
eq
(
'projects/issues/issues'
)
expect
(
presenter
.
default_view
).
to
eq
(
'projects/issues/issues'
)
...
@@ -119,12 +151,13 @@ RSpec.describe ProjectPresenter do
...
@@ -119,12 +151,13 @@ RSpec.describe ProjectPresenter do
end
end
context
'with no activity, no wikies and no issues'
do
context
'with no activity, no wikies and no issues'
do
it
'returns
customize_workflow
as default'
do
it
'returns
activity
as default'
do
project
.
project_feature
.
update_attribute
(
:issues_access_level
,
0
)
project
.
project_feature
.
update_attribute
(
:issues_access_level
,
0
)
allow
(
presenter
).
to
receive
(
:can?
).
with
(
user
,
:download_code
,
project
).
and_return
(
false
)
allow
(
presenter
).
to
receive
(
:can?
).
with
(
user
,
:download_code
,
project
).
and_return
(
false
)
allow
(
presenter
).
to
receive
(
:can?
).
with
(
user
,
:read_wiki
,
project
).
and_return
(
false
)
allow
(
presenter
).
to
receive
(
:can?
).
with
(
user
,
:read_wiki
,
project
).
and_return
(
false
)
allow
(
presenter
).
to
receive
(
:can?
).
with
(
user
,
:read_issue
,
project
).
and_return
(
false
)
expect
(
presenter
.
default_view
).
to
eq
(
'
customize_workflow
'
)
expect
(
presenter
.
default_view
).
to
eq
(
'
activity
'
)
end
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