Commit 66ebb206 authored by Christiaan Van den Poel's avatar Christiaan Van den Poel Committed by Phil Hughes

disables the shortcut to the issue boards when issues are disabled

parent 15f7f52b
...@@ -86,4 +86,8 @@ class Projects::ApplicationController < ApplicationController ...@@ -86,4 +86,8 @@ class Projects::ApplicationController < ApplicationController
def require_pages_enabled! def require_pages_enabled!
not_found unless @project.pages_available? not_found unless @project.pages_available?
end end
def check_issues_available!
return render_404 unless @project.feature_available?(:issues, current_user)
end
end end
...@@ -2,6 +2,7 @@ class Projects::BoardsController < Projects::ApplicationController ...@@ -2,6 +2,7 @@ class Projects::BoardsController < Projects::ApplicationController
include BoardsResponses include BoardsResponses
include IssuableCollections include IssuableCollections
before_action :check_issues_available!
before_action :authorize_read_board!, only: [:index, :show] before_action :authorize_read_board!, only: [:index, :show]
before_action :assign_endpoint_vars before_action :assign_endpoint_vars
......
...@@ -194,10 +194,6 @@ class Projects::IssuesController < Projects::ApplicationController ...@@ -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) render_404 unless can?(current_user, :push_code, @project) && @issue.can_be_worked_on?(current_user)
end end
def check_issues_available!
return render_404 unless @project.feature_available?(:issues, current_user)
end
def render_issue_json def render_issue_json
if @issue.valid? if @issue.valid?
render json: serializer.represent(@issue) render json: serializer.represent(@issue)
......
...@@ -299,9 +299,10 @@ ...@@ -299,9 +299,10 @@
Charts Charts
-# Shortcut to Issues > New Issue -# Shortcut to Issues > New Issue
%li.hidden - if project_nav_tab?(:issues)
= link_to new_project_issue_path(@project), class: 'shortcuts-new-issue' do %li.hidden
Create a new issue = link_to new_project_issue_path(@project), class: 'shortcuts-new-issue' do
Create a new issue
-# Shortcut to Pipelines > Jobs -# Shortcut to Pipelines > Jobs
- if project_nav_tab? :builds - if project_nav_tab? :builds
...@@ -316,5 +317,6 @@ ...@@ -316,5 +317,6 @@
Commits Commits
-# Shortcut to issue boards -# Shortcut to issue boards
%li.hidden - if project_nav_tab?(:issues)
= link_to 'Issue Boards', project_boards_path(@project), title: 'Issue Boards', class: 'shortcuts-issue-boards' %li.hidden
= link_to 'Issue Boards', project_boards_path(@project), title: 'Issue Boards', class: 'shortcuts-issue-boards'
---
title: disables shortcut to issue boards when issues are not enabled
merge_request: 16020
author: Christiaan Van den Poel
type: fixed
...@@ -55,6 +55,16 @@ describe Projects::BoardsController do ...@@ -55,6 +55,16 @@ describe Projects::BoardsController do
end end
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) def list_boards(format: :html)
get :index, namespace_id: project.namespace, get :index, namespace_id: project.namespace,
project_id: project, project_id: project,
......
require 'rails_helper' require 'rails_helper'
describe 'Issue Boards shortcut', :js do describe 'Issue Boards shortcut', :js do
let(:project) { create(:project) } context 'issues are enabled' do
let(:project) { create(:project) }
before do before do
create(:board, project: project) 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 end
it 'takes user to issue board index' do context 'issues are not enabled' do
find('body').native.send_keys('gb') let(:project) { create(:project, :issues_disabled) }
expect(page).to have_selector('.boards-list')
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')
wait_for_requests expect(page).to have_selector("body[data-page='projects:show']")
end
end end
end end
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
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