Commit 3f2dbe0e authored by Douwe Maan's avatar Douwe Maan

Merge branch 'jprovazn-epics-count-by' into 'master'

Support both integer and string as epic count key

Closes #8824

See merge request gitlab-org/gitlab-ee!8840
parents 4e12a903 700bd970
......@@ -55,7 +55,13 @@ class EpicsFinder < IssuableFinder
private
def count_key(value)
Array(value).last.to_sym
last_value = Array(value).last
if last_value.is_a?(Integer)
Epic.states.invert[last_value].to_sym
else
last_value.to_sym
end
end
# rubocop: disable CodeReuse/ActiveRecord
......
......@@ -202,5 +202,22 @@ describe EpicsFinder do
expect(results).to eq('opened' => 2, 'closed' => 1, 'all' => 3)
end
context 'when using group cte for search' do
before do
stub_feature_flags(use_subquery_for_group_issues_search: false)
end
it 'returns correct counts when search string is used' do
results = described_class.new(
search_user,
group_id: group.id,
search: 'awesome',
attempt_group_search_optimizations: true
).count_by_state
expect(results).to eq('opened' => 1, 'closed' => 1, 'all' => 2)
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