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
properly include ancestors/descendants for child and rely on includes_hierarchy
ulferts91ab869083e1
diff --git a/app/models/work_packages/scopes/relatable.rb b/app/models/work_packages/scopes/relatable.rbindex e0fb7cd75a4..45a188f6cf6 100644--- a/app/models/work_packages/scopes/relatable.rb+++ b/app/models/work_packages/scopes/relatable.rb@@ -365,9 +365,6 @@ module WorkPackages::Scopes# rubocop:enable Metrics/PerceivedComplexitydef existing_hierarchy_lateral(with_descendants: true)- hierarchy_condition = ["work_package_hierarchies.descendant_id = related.id"]- hierarchy_condition << "work_package_hierarchies.ancestor_id = related.id" if with_descendants-<<~SQL.squishSELECTCASE@@ -385,7 +382,7 @@ module WorkPackages::Scopeswork_package_hierarchiesWHERErelated.from_hierarchy = false AND- (#{hierarchy_condition.join(' OR ')})+ (work_package_hierarchies.descendant_id = related.id OR work_package_hierarchies.ancestor_id = related.id)AND (work_package_hierarchies.generations != 0)SQLenddiff --git a/spec/models/work_packages/scopes/relatable_spec.rb b/spec/models/work_packages/scopes/relatable_spec.rbindex b754a483eba..4c65cfce1cb 100644--- a/spec/models/work_packages/scopes/relatable_spec.rb+++ b/spec/models/work_packages/scopes/relatable_spec.rb@@ -1431,7 +1431,7 @@ describe WorkPackages::Scopes::Relatable, '.relatable scope' doendend- context 'with a predecessor chain where the first has parent and child' do+ context 'with a predecessor chain where the first has parent and child and that child has a predecessor' dolet(:direct_predecessor) docreate(:work_package).tap do |pre|create(:follows_relation, from: origin, to: pre)@@ -1448,8 +1448,17 @@ describe WorkPackages::Scopes::Relatable, '.relatable scope' dolet(:transitive_predecessor_child) docreate(:work_package, parent: transitive_predecessor)end+ let(:transitive_predecessor_child_predecessor) do+ create(:work_package).tap do |pre|+ create(:follows_relation, from: transitive_predecessor_child, to: pre)+ end+ endlet!(:existing_work_packages) do- [direct_predecessor, transitive_predecessor, transitive_predecessor_parent, transitive_predecessor_child]+ [direct_predecessor,+ transitive_predecessor,+ transitive_predecessor_parent,+ transitive_predecessor_child,+ transitive_predecessor_child_predecessor]endcontext "for a 'parent' relation" do