Commit 82e2d90b authored by Phil Hughes's avatar Phil Hughes

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
parents 15f7f52b 66ebb206
...@@ -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,6 +299,7 @@ ...@@ -299,6 +299,7 @@
Charts Charts
-# Shortcut to Issues > New Issue -# Shortcut to Issues > New Issue
- if project_nav_tab?(:issues)
%li.hidden %li.hidden
= link_to new_project_issue_path(@project), class: 'shortcuts-new-issue' do = link_to new_project_issue_path(@project), class: 'shortcuts-new-issue' do
Create a new issue Create a new issue
...@@ -316,5 +317,6 @@ ...@@ -316,5 +317,6 @@
Commits Commits
-# Shortcut to issue boards -# Shortcut to issue boards
- if project_nav_tab?(:issues)
%li.hidden %li.hidden
= link_to 'Issue Boards', project_boards_path(@project), title: 'Issue Boards', class: 'shortcuts-issue-boards' = 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
context 'issues are enabled' do
let(:project) { create(:project) } let(:project) { create(:project) }
before do before do
...@@ -17,4 +18,21 @@ describe 'Issue Boards shortcut', :js do ...@@ -17,4 +18,21 @@ describe 'Issue Boards shortcut', :js do
wait_for_requests wait_for_requests
end 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 issue board index' do
find('body').native.send_keys('gb')
expect(page).to have_selector("body[data-page='projects:show']")
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