OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
[31902] Ensure we pass the query_id in case of manual queries
Oliver Güntheradb94a19f8dd
diff --git a/app/services/api/v3/work_package_collection_from_query_service.rb b/app/services/api/v3/work_package_collection_from_query_service.rbindex cd70f7cdaa6..e9b6bd28b10 100644--- a/app/services/api/v3/work_package_collection_from_query_service.rb+++ b/app/services/api/v3/work_package_collection_from_query_service.rb@@ -79,6 +79,7 @@ module APIdef calculate_resulting_params(provided_params)calculate_default_params.merge(provided_params.slice('offset', 'pageSize').symbolize_keys).tap do |params|if query.manually_sorted?+ params[:query_id] = query.idparams[:offset] = 1params[:pageSize] = Setting.forced_single_page_sizeelsediff --git a/spec/features/work_packages/export_spec.rb b/spec/features/work_packages/export_spec.rbindex 8a76b1342e3..e30916a23de 100644--- a/spec/features/work_packages/export_spec.rb+++ b/spec/features/work_packages/export_spec.rb@@ -70,87 +70,127 @@ describe 'work package export', type: :feature doendbefore do- work_packages_page.visit_index- filters.expect_filter_count 1- filters.open-# render the CSV as plain text so we can run expectations against the outputexpect_any_instance_of(WorkPackagesController).to receive(:send_data) do |receiver, serialized_work_packages, _opts|- receiver.render plain: serialized_work_packages- end+ receiver.render plain: serialized_work_packages+ endendafter doDownloadedFile::clear_downloadsend- it 'shows all work packages with the default filters', js: true, retry: 2 do- export!+ context 'with default filter' do- expect(subject).to have_text(wp_1.description)- expect(subject).to have_text(wp_2.description)- expect(subject).to have_text(wp_3.description)- expect(subject).to have_text(wp_4.description)+ before do+ work_packages_page.visit_index+ filters.expect_filter_count 1+ filters.open+ end- # results are ordered by ID (asc) and not grouped by type- expect(subject.scan(/Type (A|B)/).flatten).to eq %w(A A B A)- end+ it 'shows all work packages with the default filters', js: true, retry: 2 do+ export!- it 'shows all work packages grouped by ', js: true, retry: 2 do- group_by.enable_via_menu 'Type'+ expect(subject).to have_text(wp_1.description)+ expect(subject).to have_text(wp_2.description)+ expect(subject).to have_text(wp_3.description)+ expect(subject).to have_text(wp_4.description)- wp_table.expect_work_package_listed(wp_1)- wp_table.expect_work_package_listed(wp_2)- wp_table.expect_work_package_listed(wp_3)- wp_table.expect_work_package_listed(wp_4)+ # results are ordered by ID (asc) and not grouped by type+ expect(subject.scan(/Type (A|B)/).flatten).to eq %w(A A B A)+ end- export!+ it 'shows all work packages grouped by ', js: true, retry: 2 do+ group_by.enable_via_menu 'Type'- expect(subject).to have_text(wp_1.description)- expect(subject).to have_text(wp_2.description)- expect(subject).to have_text(wp_3.description)- expect(subject).to have_text(wp_4.description)+ wp_table.expect_work_package_listed(wp_1)+ wp_table.expect_work_package_listed(wp_2)+ wp_table.expect_work_package_listed(wp_3)+ wp_table.expect_work_package_listed(wp_4)- # grouped by type- expect(subject.scan(/Type (A|B)/).flatten).to eq %w(A A A B)- end+ export!- it 'shows only the work package with the right progress if filtered this way',- js: true, retry: 2 do- filters.add_filter_by 'Progress (%)', 'is', ['25'], 'percentageDone'+ expect(subject).to have_text(wp_1.description)+ expect(subject).to have_text(wp_2.description)+ expect(subject).to have_text(wp_3.description)+ expect(subject).to have_text(wp_4.description)- sleep 1- loading_indicator_saveguard+ # grouped by type+ expect(subject.scan(/Type (A|B)/).flatten).to eq %w(A A A B)+ end- wp_table.expect_work_package_listed(wp_1)- wp_table.ensure_work_package_not_listed!(wp_2, wp_3)+ it 'shows only the work package with the right progress if filtered this way',+ js: true, retry: 2 do+ filters.add_filter_by 'Progress (%)', 'is', ['25'], 'percentageDone'- export!+ sleep 1+ loading_indicator_saveguard- expect(subject).to have_text(wp_1.description)- expect(subject).not_to have_text(wp_2.description)- expect(subject).not_to have_text(wp_3.description)- end+ wp_table.expect_work_package_listed(wp_1)+ wp_table.ensure_work_package_not_listed!(wp_2, wp_3)- it 'shows only work packages of the filtered type', js: true, retry: 2 do- filters.add_filter_by 'Type', 'is', wp_3.type.name+ export!- expect(page).to have_no_content(wp_2.description) # safeguard+ expect(subject).to have_text(wp_1.description)+ expect(subject).not_to have_text(wp_2.description)+ expect(subject).not_to have_text(wp_3.description)+ end- export!+ it 'shows only work packages of the filtered type', js: true, retry: 2 do+ filters.add_filter_by 'Type', 'is', wp_3.type.name- expect(subject).not_to have_text(wp_1.description)- expect(subject).not_to have_text(wp_2.description)- expect(subject).to have_text(wp_3.description)- end+ expect(page).to have_no_content(wp_2.description) # safeguard- it 'exports selected columns', js: true, retry: 2 do- columns.add 'Progress (%)'+ export!- export!+ expect(subject).not_to have_text(wp_1.description)+ expect(subject).not_to have_text(wp_2.description)+ expect(subject).to have_text(wp_3.description)+ end++ it 'exports selected columns', js: true, retry: 2 do+ columns.add 'Progress (%)'++ export!++ expect(subject).to have_text('Progress (%)')+ expect(subject).to have_text('25')+ end+ end- expect(subject).to have_text('Progress (%)')- expect(subject).to have_text('25')+ describe 'with a manually sorted query', js: true do+ let(:query) do+ FactoryBot.create :query,+ user: current_user,+ project: project+ end++ before do+ ::OrderedWorkPackage.create(query: query, work_package: wp_4, position: 0)+ ::OrderedWorkPackage.create(query: query, work_package: wp_1, position: 1)+ ::OrderedWorkPackage.create(query: query, work_package: wp_2, position: 2)+ ::OrderedWorkPackage.create(query: query, work_package: wp_3, position: 3)++ query.add_filter('manual_sort', 'ow', [])+ query.sort_criteria = [[:manual_sorting, 'asc']]+ query.save!+ end++ it 'returns the correct number of work packages' do+ wp_table.visit_query query+ wp_table.expect_work_package_listed(wp_1, wp_2, wp_3, wp_4)+ wp_table.expect_work_package_order(wp_4, wp_1, wp_2, wp_3)++ export!++ expect(subject).to have_text(wp_1.description)+ expect(subject).to have_text(wp_2.description)+ expect(subject).to have_text(wp_3.description)+ expect(subject).to have_text(wp_4.description)++ # results are ordered by ID (asc) and not grouped by type+ expect(subject.scan(/WorkPackage No\. \d+,/)).to eq [wp_4, wp_1, wp_2, wp_3].map { |wp| wp.subject + ',' }+ endendend