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
recreate proper associations between phases and work packages
ulferts0a7e57582b72
diff --git a/app/models/project/phase.rb b/app/models/project/phase.rbindex 48286524e59..c2773d9ab02 100644--- a/app/models/project/phase.rb+++ b/app/models/project/phase.rb@@ -31,7 +31,8 @@ class Project::Phase < ApplicationRecordbelongs_to :definition,optional: false,class_name: "Project::PhaseDefinition"- has_many :work_packages, inverse_of: :project_phase, dependent: :nullify+ has_many :work_packages,+ through: :definitionvalidate :validate_date_rangediff --git a/app/models/project/phase_definition.rb b/app/models/project/phase_definition.rbindex e49eced060b..871040c07e5 100644--- a/app/models/project/phase_definition.rb+++ b/app/models/project/phase_definition.rb@@ -38,6 +38,7 @@ class Project::PhaseDefinition < ApplicationRecorddependent: :destroyhas_many :projects, through: :phasesbelongs_to :color, optional: false+ has_many :work_packages, inverse_of: :project_phase_definition, dependent: :nullifyvalidates :name, presence: true, uniqueness: truevalidates :start_gate_name, presence: true, if: :start_gate?diff --git a/spec/models/project/phase_definition_spec.rb b/spec/models/project/phase_definition_spec.rbindex ddba4df3883..ff051a69410 100644--- a/spec/models/project/phase_definition_spec.rb+++ b/spec/models/project/phase_definition_spec.rb@@ -50,5 +50,6 @@ RSpec.describe Project::PhaseDefinition doit { is_expected.to have_many(:projects).through(:phases) }it { is_expected.to belong_to(:color).required }+ it { is_expected.to have_many(:work_packages) }endenddiff --git a/spec/models/project/phase_spec.rb b/spec/models/project/phase_spec.rbindex d2f0f90df36..1ea5c7416f7 100644--- a/spec/models/project/phase_spec.rb+++ b/spec/models/project/phase_spec.rb@@ -38,7 +38,7 @@ RSpec.describe Project::Phase dodescribe "associations" doit { is_expected.to belong_to(:project).required }it { is_expected.to belong_to(:definition).required }- it { is_expected.to have_many(:work_packages) }+ it { is_expected.to have_many(:work_packages).through(:definition) }enddescribe ".visible" do