Merge branch '41244-issue-board-shortcut-working-while-no-issues' into 'master'

disables the shortcut to the issue boards when issues are disabled

Closes #41244

See merge request gitlab-org/gitlab-ce!16020
This commit is contained in:
Phil Hughes 2018-01-08 09:08:02 +00:00
commit 82e2d90b51
8 changed files with 90 additions and 18 deletions

View File

@ -86,4 +86,8 @@ class Projects::ApplicationController < ApplicationController
def require_pages_enabled!
not_found unless @project.pages_available?
end
def check_issues_available!
return render_404 unless @project.feature_available?(:issues, current_user)
end
end

View File

@ -2,6 +2,7 @@ class Projects::BoardsController < Projects::ApplicationController
include BoardsResponses
include IssuableCollections
before_action :check_issues_available!
before_action :authorize_read_board!, only: [:index, :show]
before_action :assign_endpoint_vars

View File

@ -194,10 +194,6 @@ class Projects::IssuesController < Projects::ApplicationController
render_404 unless can?(current_user, :push_code, @project) && @issue.can_be_worked_on?(current_user)
end
def check_issues_available!
return render_404 unless @project.feature_available?(:issues, current_user)
end
def render_issue_json
if @issue.valid?
render json: serializer.represent(@issue)

View File

@ -299,9 +299,10 @@
Charts
-# Shortcut to Issues > New Issue
%li.hidden
= link_to new_project_issue_path(@project), class: 'shortcuts-new-issue' do
Create a new issue
- if project_nav_tab?(:issues)
%li.hidden
= link_to new_project_issue_path(@project), class: 'shortcuts-new-issue' do
Create a new issue
-# Shortcut to Pipelines > Jobs
- if project_nav_tab? :builds
@ -316,5 +317,6 @@
Commits
-# Shortcut to issue boards
%li.hidden
= link_to 'Issue Boards', project_boards_path(@project), title: 'Issue Boards', class: 'shortcuts-issue-boards'
- if project_nav_tab?(:issues)
%li.hidden
= link_to 'Issue Boards', project_boards_path(@project), title: 'Issue Boards', class: 'shortcuts-issue-boards'

View File

@ -0,0 +1,5 @@
---
title: disables shortcut to issue boards when issues are not enabled
merge_request: 16020
author: Christiaan Van den Poel
type: fixed

View File

@ -55,6 +55,16 @@ describe Projects::BoardsController do
end
end
context 'issues are disabled' do
let(:project) { create(:project, :issues_disabled) }
it 'returns a not found 404 response' do
list_boards
expect(response).to have_gitlab_http_status(404)
end
end
def list_boards(format: :html)
get :index, namespace_id: project.namespace,
project_id: project,

View File

@ -1,20 +1,38 @@
require 'rails_helper'
describe 'Issue Boards shortcut', :js do
let(:project) { create(:project) }
context 'issues are enabled' do
let(:project) { create(:project) }
before do
create(:board, project: project)
before do
create(:board, project: project)
sign_in(create(:admin))
sign_in(create(:admin))
visit project_path(project)
visit project_path(project)
end
it 'takes user to issue board index' do
find('body').native.send_keys('gb')
expect(page).to have_selector('.boards-list')
wait_for_requests
end
end
it 'takes user to issue board index' do
find('body').native.send_keys('gb')
expect(page).to have_selector('.boards-list')
context 'issues are not enabled' do
let(:project) { create(:project, :issues_disabled) }
wait_for_requests
before do
sign_in(create(:admin))
visit project_path(project)
end
it 'does not take user to the issue board index' do
find('body').native.send_keys('gb')
expect(page).to have_selector("body[data-page='projects:show']")
end
end
end

View File

@ -0,0 +1,36 @@
require 'rails_helper'
describe 'Issues shortcut', :js do
context 'New Issue shortcut' do
context 'issues are enabled' do
let(:project) { create(:project) }
before do
sign_in(create(:admin))
visit project_path(project)
end
it 'takes user to the new issue page' do
find('body').native.send_keys('i')
expect(page).to have_selector('#new_issue')
end
end
context 'issues are not enabled' do
let(:project) { create(:project, :issues_disabled) }
before do
sign_in(create(:admin))
visit project_path(project)
end
it 'does not take user to the new issue page' do
find('body').native.send_keys('i')
expect(page).to have_selector("body[data-page='projects:show']")
end
end
end
end