diff --git a/app/controllers/concerns/work_items_collections.rb b/app/controllers/concerns/work_items_collections.rb index 59283fb1b5bffd1e439757b8b7ccae3a15e329cd..2df2734969f6e21ef0b76d970202be4a649dc134 100644 --- a/app/controllers/concerns/work_items_collections.rb +++ b/app/controllers/concerns/work_items_collections.rb @@ -36,6 +36,14 @@ def work_items_for_calendar def finder_options work_items_collection_params[:state] = (params.permit([:state])[:state].presence || default_state) + # Handle the translation of the type param, since the finder expects :issue_types + types = params.permit(type: [])[:type] + work_items_collection_params[:issue_types] = types if types + + if work_items_collection_params.dig(:not, :type) + work_items_collection_params[:not][:issue_types] = work_items_collection_params[:not].delete(:type) + end + options = { scope: params.permit([:scope])[:scope], state: work_items_collection_params[:state], diff --git a/spec/controllers/concerns/work_items_collections_spec.rb b/spec/controllers/concerns/work_items_collections_spec.rb index a10b242f6e32a05f86401997af230e586d21039d..be823035e7451b28f288c779734a99750ed3d6a0 100644 --- a/spec/controllers/concerns/work_items_collections_spec.rb +++ b/spec/controllers/concerns/work_items_collections_spec.rb @@ -116,5 +116,21 @@ def finder_type }) end end + + context 'with type filtering' do + let(:params) { { type: %w[task incident] } } + + it 'mutates the search into a filter by type' do + is_expected.to include({ issue_types: %w[task incident] }) + end + end + + context 'with negated type filtering' do + let(:params) { { not: { type: %w[task incident] } } } + + it 'mutates the search into a filter by type' do + is_expected.to include({ not: { issue_types: %w[task incident] } }) + end + end end end