Skip to content

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

phase order_by_position scope

Ivan Kuchinc770bf55ed3e
diff --git a/app/models/project.rb b/app/models/project.rb
index e941a1ce913..8a52e52cb85 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -88,7 +88,7 @@ class Project < ApplicationRecord
has_many :storages, through: :project_storages
has_many :phases, class_name: "Project::Phase", dependent: :destroy
has_many :available_phases,
- -> { visible.eager_load(:definition).order(position: :asc) },
+ -> { visible.order_by_position },
class_name: "Project::Phase",
inverse_of: :project
diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb
index c35935a5a78..03f863800d5 100644
--- a/spec/models/project_spec.rb
+++ b/spec/models/project_spec.rb
@@ -389,7 +389,7 @@ RSpec.describe Project do
.class_name("Project::Phase")
.inverse_of(:project)
.dependent(nil)
- .order(position: :asc)
+ .order("project_phase_definitions.position ASC")
end
it "checks for active flag" do