Skip to content
代码片段 群组 项目
未验证 提交 dff8ecce 编辑于 作者: Arturo Herrero's avatar Arturo Herrero 提交者: GitLab
浏览文件

Advance Search: Merge request with labels

EE: true
上级 4c1dc851
No related branches found
No related tags found
无相关合并请求
---
name: search_mr_filter_label_ids
feature_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/464090
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/160425
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/473796
milestone: '17.3'
group: group::global search
type: gitlab_com_derisk
default_enabled: false
......@@ -326,9 +326,9 @@ def scope_options(scope)
when :projects, :notes, :commits
base_options.merge(filters.slice(:include_archived))
when :merge_requests
base_options
.merge(filters.slice(:order_by, :sort, :state, :include_archived, :source_branch, :not_source_branch,
:author_username, :not_author_username))
base_options.merge(
filters.slice(:order_by, :sort, :state, :include_archived, :source_branch, :not_source_branch,
:author_username, :not_author_username, :label_name))
when :issues
base_options.merge(
filters.slice(:order_by, :sort, :confidential, :state, :labels, :label_name, :include_archived),
......
......@@ -40,6 +40,11 @@ def build
query_hash = ::Search::Elastic::Filters.by_not_hidden(query_hash: query_hash, options: options)
end
if Feature.enabled?(:search_mr_filter_label_ids, options[:current_user]) &&
::Elastic::DataMigrationService.migration_has_finished?(:reindex_merge_requests_to_backfill_label_ids)
query_hash = ::Search::Elastic::Filters.by_label_ids(query_hash: query_hash, options: options)
end
query_hash = ::Search::Elastic::Formats.source_fields(query_hash: query_hash, options: options)
query_hash = ::Search::Elastic::Formats.size(query_hash: query_hash, options: options)
......
......@@ -181,6 +181,54 @@
end
end
end
describe 'labels' do
let_it_be(:label) { create(:label, project: authorized_project) }
before do
set_elasticsearch_migration_to(:reindex_merge_requests_to_backfill_label_ids, including: true)
end
context 'when search_mr_filter_label_ids flag is false' do
before do
stub_feature_flags(search_mr_filter_label_ids: false)
end
it 'does not include labels filter by default' do
assert_names_in_query(build, without: %w[filters:label_ids])
end
context 'when label_name option is provided' do
let(:options) { base_options.merge(label_name: [label.name]) }
it 'does not include labels filter' do
assert_names_in_query(build, without: %w[filters:label_ids])
end
end
end
it 'does not include labels filter by default' do
assert_names_in_query(build, without: %w[filters:label_ids])
end
context 'when label_name option is provided' do
let(:options) { base_options.merge(label_name: [label.name]) }
it 'applies label filters' do
assert_names_in_query(build, with: %w[filters:label_ids])
end
context 'when the migration is not finished' do
before do
set_elasticsearch_migration_to(:reindex_merge_requests_to_backfill_label_ids, including: false)
end
it 'does not include labels filter' do
assert_names_in_query(build, without: %w[filters:label_ids])
end
end
end
end
end
it_behaves_like 'a sorted query'
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册