BigW Consortium Gitlab

Commit c0632f14 by James Clark

Hide clone panel and file list when user is only a guest

Fixes gitlab-org/gitlab-ce#17489 Fix test finding two of the same element Capybara will raise an exception because it finds two elements that match .nav-links. This means this test would fail, even if the page meets the conditions for passing the test. Add more tests for guest access
parent 6ad3814e
......@@ -257,7 +257,7 @@ class ProjectsController < Projects::ApplicationController
#
# pages list order: repository readme, wiki home, issues list, customize workflow
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?
render 'projects/empty' if @project.empty_repo?
else
......
......@@ -49,7 +49,7 @@ module PreferencesHelper
user_view = current_user.project_view
if @project.feature_available?(:repository, current_user)
if can?(current_user, :download_code, @project)
user_view
elsif user_view == "activity"
"activity"
......
......@@ -24,7 +24,7 @@
= render 'projects/buttons/fork'
%span.hidden-xs
- if @project.feature_available?(:repository, current_user)
- if can?(current_user, :download_code, @project)
.project-clone-holder
= render "shared/clone_panel"
......
---
title: Hide clone panel and file list when user is only a guest
merge_request:
author: James Clark
......@@ -13,7 +13,7 @@ describe "Guest navigation menu" do
it "shows allowed tabs only" do
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 'Issues'
expect(page).to have_content 'Wiki'
......@@ -23,4 +23,51 @@ describe "Guest navigation menu" do
expect(page).not_to have_content 'Merge Requests'
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_attribute("issues_access_level", ProjectFeature::DISABLED)
project.project_feature.update_attribute("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'
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_attribute("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_attribute("issues_access_level", ProjectFeature::PRIVATE)
visit namespace_project_path(project.namespace, project)
expect(page).to have_selector '.issues-list'
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