Commit dcf55400 authored by Felipe Artur's avatar Felipe Artur

Hide test cases from issues list

Hide test cases issues from issues list
parent a1f13438
...@@ -344,10 +344,12 @@ class Projects::IssuesController < Projects::ApplicationController ...@@ -344,10 +344,12 @@ class Projects::IssuesController < Projects::ApplicationController
def finder_options def finder_options
options = super options = super
return options unless service_desk? options[:issue_types] = Issue::TYPES_FOR_LIST
if service_desk?
options.reject! { |key| key == 'author_username' || key == 'author_id' } options.reject! { |key| key == 'author_username' || key == 'author_id' }
options[:author_id] = User.support_bot options[:author_id] = User.support_bot
end
options options
end end
......
...@@ -30,6 +30,11 @@ class Issue < ApplicationRecord ...@@ -30,6 +30,11 @@ class Issue < ApplicationRecord
SORTING_PREFERENCE_FIELD = :issues_sort 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 belongs_to :project
has_one :namespace, through: :project has_one :namespace, through: :project
......
...@@ -68,10 +68,12 @@ module Projects ...@@ -68,10 +68,12 @@ module Projects
# Check https://gitlab.com/gitlab-org/gitlab-foss/issues/38418 description. # Check https://gitlab.com/gitlab-org/gitlab-foss/issues/38418 description.
# rubocop: disable CodeReuse/ActiveRecord # rubocop: disable CodeReuse/ActiveRecord
def self.query(projects, public_only: true) def self.query(projects, public_only: true)
issues_filtered_by_type = Issue.opened.with_issue_type(Issue::TYPES_FOR_LIST)
if public_only if public_only
Issue.opened.public_only.where(project: projects) issues_filtered_by_type.public_only.where(project: projects)
else else
Issue.opened.where(project: projects) issues_filtered_by_type.where(project: projects)
end end
end end
# rubocop: enable CodeReuse/ActiveRecord # rubocop: enable CodeReuse/ActiveRecord
......
...@@ -82,6 +82,16 @@ RSpec.describe Projects::IssuesController do ...@@ -82,6 +82,16 @@ RSpec.describe Projects::IssuesController do
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
end 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 it "returns 301 if request path doesn't match project path" do
get :index, params: { namespace_id: project.namespace, project_id: project.path.upcase } 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 ...@@ -10,6 +10,14 @@ RSpec.describe Projects::OpenIssuesCountService, :use_clean_rails_memory_store_c
it_behaves_like 'a counter caching service' it_behaves_like 'a counter caching service'
describe '#count' do 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 context 'when user is nil' do
it 'does not include confidential issues in the issue count' do it 'does not include confidential issues in the issue count' do
create(:issue, :opened, project: project) 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