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
Remove Project#life_cycles association, remove Project::LifeCycle#date database field and use start_date instead.
Dombi Attila0885c1d3511e
diff --git a/app/models/project.rb b/app/models/project.rbindex 0893018a0ba..7799b0ed094 100644--- a/app/models/project.rb+++ b/app/models/project.rb@@ -87,7 +87,6 @@ class Project < ApplicationRecordhas_many :project_storages, dependent: :destroy, class_name: "Storages::ProjectStorage"has_many :storages, through: :project_storageshas_many :project_life_cycles, class_name: "Project::LifeCycle", dependent: :destroy- has_many :life_cycles, through: :project_life_cyclesstore_attribute :settings, :deactivate_work_package_attachments, :booleandiff --git a/app/models/project/gate.rb b/app/models/project/gate.rbindex 1aef0ec5464..211001e2740 100644--- a/app/models/project/gate.rb+++ b/app/models/project/gate.rb@@ -27,12 +27,14 @@#++class Project::Gate < Project::LifeCycle+ alias_attribute :date, :start_date+validates :date, presence: true- validate :validate_restricted_attributes+ validate :end_date_not_allowed- def validate_restricted_attributes- if start_date.present? || end_date.present?- errors.add(:base, :date_range_not_allowed)+ def end_date_not_allowed+ if end_date.present?+ errors.add(:base, :end_date_not_allowed)endendenddiff --git a/app/models/project/stage.rb b/app/models/project/stage.rbindex 31a82be13ff..afd6090a067 100644--- a/app/models/project/stage.rb+++ b/app/models/project/stage.rb@@ -28,11 +28,4 @@class Project::Stage < Project::LifeCyclevalidates :start_date, :end_date, presence: true- validate :validate_restricted_attributes-- def validate_restricted_attributes- if date.present?- errors.add(:base, :date_not_allowed)- end- endenddiff --git a/config/locales/en.yml b/config/locales/en.ymlindex 290f07d11ff..b1286e98254 100644--- a/config/locales/en.yml+++ b/config/locales/en.yml@@ -1121,11 +1121,7 @@ en:project/gate:attributes:base:- date_range_not_allowed: "Cannot assign `start_date` or `end_date` to a Gate"- project/stage:- attributes:- base:- date_not_allowed: "Cannot assign `date` to a Stage"+ end_date_not_allowed: "Cannot assign `end_date` to a Gate"query:attributes:project:diff --git a/db/migrate/20241105151352_create_project_life_cycles.rb b/db/migrate/20241105151352_create_project_life_cycles.rbindex e5576093b07..3aab5365def 100644--- a/db/migrate/20241105151352_create_project_life_cycles.rb+++ b/db/migrate/20241105151352_create_project_life_cycles.rb@@ -4,7 +4,6 @@ class CreateProjectLifeCycles < ActiveRecord::Migration[7.1]t.string :typet.date :start_datet.date :end_date- t.date :datet.references :project, foreign_key: truet.references :life_cycle, foreign_key: truediff --git a/spec/models/project/gate_spec.rb b/spec/models/project/gate_spec.rbindex b4408cd86bc..49a594e78e1 100644--- a/spec/models/project/gate_spec.rb+++ b/spec/models/project/gate_spec.rb@@ -35,21 +35,14 @@ RSpec.describe Project::Gate dodescribe "validations" doit { is_expected.to validate_presence_of(:date) }- it "is invalid if `start_date` is present" do- gate_with_start_date = build(:project_gate, start_date: Time.zone.today)-- expect(gate_with_start_date).not_to be_valid- expect(gate_with_start_date.errors[:base]).to include("Cannot assign `start_date` or `end_date` to a Gate")- end-it "is invalid if `end_date` is present" dogate_with_end_date = build(:project_gate, end_date: Time.zone.today)expect(gate_with_end_date).not_to be_valid- expect(gate_with_end_date.errors[:base]).to include("Cannot assign `start_date` or `end_date` to a Gate")+ expect(gate_with_end_date.errors[:base]).to include("Cannot assign `end_date` to a Gate")end- it "is valid if neither `start_date` nor `end_date` are present" do+ it "is valid if `end_date` is not present" dovalid_gate = build(:project_gate)expect(valid_gate).to be_validenddiff --git a/spec/models/project/stage_spec.rb b/spec/models/project/stage_spec.rbindex 6e2ac4f2ee6..35b8231ed08 100644--- a/spec/models/project/stage_spec.rb+++ b/spec/models/project/stage_spec.rb@@ -40,12 +40,5 @@ RSpec.describe Project::Stage dovalid_stage = build(:project_stage)expect(valid_stage).to be_validend-- it "adds an error when `date` is set" do- stage_with_date = build(:project_stage, date: Time.zone.today)-- expect(stage_with_date).not_to be_valid- expect(stage_with_date.errors[:base]).to include("Cannot assign `date` to a Stage")- endendenddiff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rbindex 01e21868959..57cce3c2cce 100644--- a/spec/models/project_spec.rb+++ b/spec/models/project_spec.rb@@ -383,7 +383,6 @@ RSpec.describe Project dodescribe "life_cycles" doit { is_expected.to have_many(:project_life_cycles).class_name("Project::LifeCycle").dependent(:destroy) }- it { is_expected.to have_many(:life_cycles).through(:project_life_cycles) }enddescribe "#enabled_module_names=", with_settings: { default_projects_modules: %w(work_package_tracking repository) } do