Commit e21d075c authored by Douwe Maan's avatar Douwe Maan

Merge branch '17489-hide-code-from-guests' into 'master'

Hide clone panel and file list when user is only a guest (with review comments addressed)

Closes #30432, #3142, and #17489

See merge request !11631
parents b00c268b 2158bedd
...@@ -257,7 +257,7 @@ class ProjectsController < Projects::ApplicationController ...@@ -257,7 +257,7 @@ class ProjectsController < Projects::ApplicationController
# #
# pages list order: repository readme, wiki home, issues list, customize workflow # pages list order: repository readme, wiki home, issues list, customize workflow
def render_landing_page def render_landing_page
if @project.feature_available?(:repository, current_user) if can?(current_user, :download_code, @project)
return render 'projects/no_repo' unless @project.repository_exists? return render 'projects/no_repo' unless @project.repository_exists?
render 'projects/empty' if @project.empty_repo? render 'projects/empty' if @project.empty_repo?
else else
......
...@@ -49,7 +49,7 @@ module PreferencesHelper ...@@ -49,7 +49,7 @@ module PreferencesHelper
user_view = current_user.project_view user_view = current_user.project_view
if @project.feature_available?(:repository, current_user) if can?(current_user, :download_code, @project)
user_view user_view
elsif user_view == "activity" elsif user_view == "activity"
"activity" "activity"
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
= render 'projects/buttons/fork' = render 'projects/buttons/fork'
%span.hidden-xs %span.hidden-xs
- if @project.feature_available?(:repository, current_user) - if can?(current_user, :download_code, @project)
.project-clone-holder .project-clone-holder
= render "shared/clone_panel" = render "shared/clone_panel"
......
---
title: Hide clone panel and file list when user is only a guest
merge_request:
author: James Clark
require 'spec_helper' require 'spec_helper'
describe "Guest navigation menu" do describe 'Guest navigation menu' do
let(:project) { create(:empty_project, :private, public_builds: false) } let(:project) { create(:empty_project, :private, public_builds: false) }
let(:guest) { create(:user) } let(:guest) { create(:user) }
...@@ -10,10 +10,10 @@ describe "Guest navigation menu" do ...@@ -10,10 +10,10 @@ describe "Guest navigation menu" do
login_as(guest) login_as(guest)
end end
it "shows allowed tabs only" do it 'shows allowed tabs only' do
visit namespace_project_path(project.namespace, project) visit namespace_project_path(project.namespace, project)
within(".nav-links") do within('.layout-nav') do
expect(page).to have_content 'Project' expect(page).to have_content 'Project'
expect(page).to have_content 'Issues' expect(page).to have_content 'Issues'
expect(page).to have_content 'Wiki' expect(page).to have_content 'Wiki'
...@@ -23,4 +23,60 @@ describe "Guest navigation menu" do ...@@ -23,4 +23,60 @@ describe "Guest navigation menu" do
expect(page).not_to have_content 'Merge Requests' expect(page).not_to have_content 'Merge Requests'
end end
end end
it 'does not show fork button' do
visit namespace_project_path(project.namespace, project)
within('.count-buttons') do
expect(page).not_to have_link 'Fork'
end
end
it 'does not show clone path' do
visit namespace_project_path(project.namespace, project)
within('.project-repo-buttons') do
expect(page).not_to have_selector '.project-clone-holder'
end
end
describe 'project landing page' do
before do
project.project_feature.update!(
issues_access_level: ProjectFeature::DISABLED,
wiki_access_level: ProjectFeature::DISABLED
)
end
it 'does not show the project file list landing page' do
visit namespace_project_path(project.namespace, 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-customize_workflow'
end
it 'shows the customize workflow when issues and wiki are disabled' do
visit namespace_project_path(project.namespace, project)
expect(page).to have_selector '.project-show-customize_workflow'
end
it 'shows the wiki when enabled' do
project.project_feature.update!(wiki_access_level: ProjectFeature::PRIVATE)
visit namespace_project_path(project.namespace, 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::PRIVATE)
visit namespace_project_path(project.namespace, project)
expect(page).to have_selector '.issues-list'
end
end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment