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
Fix error when filtering by backlog type Task
Christophe Bliarda85a99de524c
diff --git a/modules/backlogs/lib/open_project/backlogs/work_package_filter.rb b/modules/backlogs/lib/open_project/backlogs/work_package_filter.rbindex 87fc0f8d7b4..1d077c98bae 100644--- a/modules/backlogs/lib/open_project/backlogs/work_package_filter.rb+++ b/modules/backlogs/lib/open_project/backlogs/work_package_filter.rb@@ -1,3 +1,5 @@+# frozen_string_literal: true+#-- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH@@ -122,27 +124,20 @@ module OpenProject::Backlogsenddef sql_for_task- <<-SQL+ <<-SQL.squish(#{db_table}.type_id = #{Task.type} AND- #{db_table}.id IN (#{is_child_sql}))+ #{db_table}.parent_id IS NOT NULL)SQLenddef sql_for_impediment- <<-SQL+ <<-SQL.squish(#{db_table}.type_id = #{Task.type} AND#{db_table}.id IN (#{blocks_backlogs_type_sql})- AND #{db_table}.id NOT IN (#{is_child_sql}))+ AND #{db_table}.parent_id IS NULL)SQLend- def is_child_sql- Relation- .hierarchy- .select(:to_id)- .to_sql- end-def blocks_backlogs_type_sqlall_types = (Story.types + [Task.type]).map(&:to_s)diff --git a/modules/backlogs/spec/features/work_packages/filter_spec.rb b/modules/backlogs/spec/features/work_packages/filter_spec.rbindex 23d78e13b33..320a75a8656 100644--- a/modules/backlogs/spec/features/work_packages/filter_spec.rb+++ b/modules/backlogs/spec/features/work_packages/filter_spec.rb@@ -64,6 +64,7 @@ RSpec.describe "Filter by backlog type", :js dolet(:work_package_with_task_type) docreate(:work_package,type: task_type,+ parent: work_package_with_story_type,project:)end@@ -105,4 +106,22 @@ RSpec.describe "Filter by backlog type", :js dofilters.expect_filter_by("Backlog type", "is (OR)", "Story", "backlogsWorkPackageType")end++ it "can filter by task or any" do+ filters.open++ filters.add_filter_by("Backlog type", "is (OR)", "Story", "backlogsWorkPackageType")++ wp_table.ensure_work_package_not_listed! work_package_with_task_type++ filters.remove_filter "backlogsWorkPackageType"+ filters.add_filter_by("Backlog type", "is (OR)", "Task", "backlogsWorkPackageType")++ wp_table.expect_work_package_listed work_package_with_task_type++ filters.remove_filter "backlogsWorkPackageType"+ filters.add_filter_by("Backlog type", "is (OR)", "any", "backlogsWorkPackageType")++ wp_table.expect_work_package_listed work_package_with_story_type, work_package_with_task_type+ endend