diff --git a/app/services/api/v3/parse_query_params_service.rb b/app/services/api/v3/parse_query_params_service.rb index 05118227a7..a69cbcf520 100644 --- a/app/services/api/v3/parse_query_params_service.rb +++ b/app/services/api/v3/parse_query_params_service.rb @@ -131,7 +131,7 @@ module API return unless highlighted_attributes.present? - highlighted_attributes.map do |attr| + highlighted_attributes.map do |href| attr = href.split('/').last convert_attribute(attr) end diff --git a/spec/features/work_packages/highlighting_spec.rb b/spec/features/work_packages/highlighting_spec.rb index 6b915ecb9d..e717330a7d 100644 --- a/spec/features/work_packages/highlighting_spec.rb +++ b/spec/features/work_packages/highlighting_spec.rb @@ -17,6 +17,7 @@ describe 'Work Package highlighting fields', FactoryBot.create :work_package, project: project, status: status1, + subject: 'B', due_date: (Date.today - 1.days), priority: priority1 end @@ -25,13 +26,14 @@ describe 'Work Package highlighting fields', FactoryBot.create :work_package, project: project, status: status2, + subject: 'A', due_date: Date.today, priority: priority_no_color end let(:wp_table) { Pages::WorkPackagesTable.new(project) } let(:highlighting) { ::Components::WorkPackages::Highlighting.new } - let!(:work_package) { FactoryBot.create :work_package, project: project } + let(:sort_by) { ::Components::WorkPackages::SortBy.new } let!(:query) do query = FactoryBot.build(:query, user: user, project: project) @@ -186,4 +188,17 @@ describe 'Work Package highlighting fields', expect(page).to have_selector(".wp-status-button .__hl_background_status_#{status1.id}") expect(page).to have_selector(".__hl_inline_priority_#{priority1.id}") end + + it 'correctly parses custom selected inline attributes' do + # Highlight only one attribute + highlighting.switch_inline_attribute_highlight "Priority" + + # Regression test, resort table + sort_by.sort_via_header 'Subject' + wp_table.expect_work_package_order wp_2, wp_1 + + # Regression test, resort table + sort_by.sort_via_header 'Subject', descending: true + wp_table.expect_work_package_order wp_1, wp_2 + end end diff --git a/spec/services/api/v3/parse_query_params_service_spec.rb b/spec/services/api/v3/parse_query_params_service_spec.rb index 3997df199d..f68d52d80f 100644 --- a/spec/services/api/v3/parse_query_params_service_spec.rb +++ b/spec/services/api/v3/parse_query_params_service_spec.rb @@ -133,6 +133,12 @@ describe ::API::V3::ParseQueryParamsService, # Please note, that dueDate is expected to get translated to due_date. let(:expected) { { highlighted_attributes: %w(status type priority due_date) } } end + + it_behaves_like 'transforms' do + let(:params) { { highlightedAttributes: %w(/api/v3/columns/status /api/v3/columns/type) } } + # Please note, that dueDate is expected to get translated to due_date. + let(:expected) { { highlighted_attributes: %w(status type) } } + end end context 'without highlighted_attributes' do