Commit 21dc0069 authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Merge branch 'issue_233479_hide_from_issues_list' into 'master'

Hide test cases from project issues list

See merge request gitlab-org/gitlab!42092
parents 655c99d6 dcf55400
......@@ -344,10 +344,12 @@ class Projects::IssuesController < Projects::ApplicationController
def finder_options
options = super
return options unless service_desk?
options[:issue_types] = Issue::TYPES_FOR_LIST
options.reject! { |key| key == 'author_username' || key == 'author_id' }
options[:author_id] = User.support_bot
if service_desk?
options.reject! { |key| key == 'author_username' || key == 'author_id' }
options[:author_id] = User.support_bot
end
options
end
......
......@@ -30,6 +30,11 @@ class Issue < ApplicationRecord
SORTING_PREFERENCE_FIELD = :issues_sort
# Types of issues that should be displayed on lists across the app
# for example, project issues list, group issues list and issue boards.
# Some issue types, like test cases, should be hidden by default.
TYPES_FOR_LIST = %w(issue incident).freeze
belongs_to :project
has_one :namespace, through: :project
......
......@@ -68,10 +68,12 @@ module Projects
# Check https://gitlab.com/gitlab-org/gitlab-foss/issues/38418 description.
# rubocop: disable CodeReuse/ActiveRecord
def self.query(projects, public_only: true)
issues_filtered_by_type = Issue.opened.with_issue_type(Issue::TYPES_FOR_LIST)
if public_only
Issue.opened.public_only.where(project: projects)
issues_filtered_by_type.public_only.where(project: projects)
else
Issue.opened.where(project: projects)
issues_filtered_by_type.where(project: projects)
end
end
# rubocop: enable CodeReuse/ActiveRecord
......
......@@ -82,6 +82,16 @@ RSpec.describe Projects::IssuesController do
expect(response).to have_gitlab_http_status(:ok)
end
it 'returns only list type issues' do
issue = create(:issue, project: project)
incident = create(:issue, project: project, issue_type: 'incident')
create(:issue, project: project, issue_type: 'test_case')
get :index, params: { namespace_id: project.namespace, project_id: project }
expect(assigns(:issues)).to contain_exactly(issue, incident)
end
it "returns 301 if request path doesn't match project path" do
get :index, params: { namespace_id: project.namespace, project_id: project.path.upcase }
......
......@@ -10,6 +10,14 @@ RSpec.describe Projects::OpenIssuesCountService, :use_clean_rails_memory_store_c
it_behaves_like 'a counter caching service'
describe '#count' do
it 'does not count test cases' do
create(:issue, :opened, project: project)
create(:incident, :opened, project: project)
create(:quality_test_case, :opened, project: project)
expect(described_class.new(project).count).to eq(2)
end
context 'when user is nil' do
it 'does not include confidential issues in the issue count' do
create(:issue, :opened, project: project)
......
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