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
Rename LifeCycle to Project::LifeCycleStepDefinition, Stage to Project::StageDefinition and Gate to Project::GateDefinition
Dombi Attila6270213e59a9
diff --git a/app/models/project.rb b/app/models/project.rbindex 7799b0ed094..89191c1eba8 100644--- a/app/models/project.rb+++ b/app/models/project.rb@@ -86,7 +86,7 @@ class Project < ApplicationRecordhas_many :notification_settings, dependent: :destroyhas_many :project_storages, dependent: :destroy, class_name: "Storages::ProjectStorage"has_many :storages, through: :project_storages- has_many :project_life_cycles, class_name: "Project::LifeCycle", dependent: :destroy+ has_many :life_cycle_steps, class_name: "Project::LifeCycleStep", dependent: :destroystore_attribute :settings, :deactivate_work_package_attachments, :booleandiff --git a/app/models/project/gate.rb b/app/models/project/gate.rbindex 211001e2740..f83dc6ce756 100644--- a/app/models/project/gate.rb+++ b/app/models/project/gate.rb@@ -26,7 +26,7 @@# See COPYRIGHT and LICENSE files for more details.#++-class Project::Gate < Project::LifeCycle+class Project::Gate < Project::LifeCycleStepalias_attribute :date, :start_datevalidates :date, presence: truediff --git a/app/models/stage.rb b/app/models/project/gate_definition.rbsimilarity index 84%rename from app/models/stage.rbrename to app/models/project/gate_definition.rbindex e235c9c450a..1eb7a16aec9 100644--- a/app/models/stage.rb+++ b/app/models/project/gate_definition.rb@@ -26,5 +26,9 @@# See COPYRIGHT and LICENSE files for more details.#++-class Stage < LifeCycle+class Project::GateDefinition < Project::LifeCycleStepDefinition+ has_many :gates, # Alias for life_cycle_steps+ class_name: "Project::Gate",+ foreign_key: :definition_id,+ dependent: :destroyenddiff --git a/app/models/project/life_cycle.rb b/app/models/project/life_cycle_step.rbsimilarity index 81%rename from app/models/project/life_cycle.rbrename to app/models/project/life_cycle_step.rbindex 91a678dbe29..5ad1d8dbed9 100644--- a/app/models/project/life_cycle.rb+++ b/app/models/project/life_cycle_step.rb@@ -26,19 +26,22 @@# See COPYRIGHT and LICENSE files for more details.#++-class Project::LifeCycle < ApplicationRecord+class Project::LifeCycleStep < ApplicationRecordbelongs_to :project, optional: false- belongs_to :life_cycle, optional: false, class_name: "::LifeCycle"- has_many :work_packages, inverse_of: :project_life_cycle, dependent: :nullify+ belongs_to :definition,+ optional: false,+ class_name: "Project::LifeCycleStepDefinition"- attr_readonly :life_cycle_id+ has_many :work_packages, inverse_of: :life_cycle_step, dependent: :nullify++ attr_readonly :definition_idvalidates :type, inclusion: { in: %w[Project::Stage Project::Gate], message: :must_be_a_stage_or_gate }def initialize(*args)- if instance_of? Project::LifeCycle+ if instance_of? Project::LifeCycleStep# Do not allow directly instantiating this class- raise NotImplementedError, "Cannot instantiate the base Project::LifeCycle class directly. " \+ raise NotImplementedError, "Cannot instantiate the base Project::LifeCycleStep class directly. " \"Use Project::Stage or Project::Gate instead."enddiff --git a/app/models/life_cycle.rb b/app/models/project/life_cycle_step_definition.rbsimilarity index 68%rename from app/models/life_cycle.rbrename to app/models/project/life_cycle_step_definition.rbindex 56176327bd1..2006d38d6a9 100644--- a/app/models/life_cycle.rb+++ b/app/models/project/life_cycle_step_definition.rb@@ -26,20 +26,23 @@# See COPYRIGHT and LICENSE files for more details.#++-class LifeCycle < ApplicationRecord- has_many :project_life_cycles, class_name: "Project::LifeCycle", dependent: :destroy- has_many :projects, through: :project_life_cycles+class Project::LifeCycleStepDefinition < ApplicationRecord+ has_many :life_cycle_steps,+ class_name: "Project::LifeCycleStep",+ foreign_key: :definition_id,+ dependent: :destroy+ has_many :projects, through: :life_cycle_stepsbelongs_to :color, optional: falsevalidates :name, presence: true- validates :type, inclusion: { in: %w[Stage Gate], message: :must_be_a_stage_or_gate }+ validates :type, inclusion: { in: %w[Project::StageDefinition Project::GateDefinition], message: :must_be_a_stage_or_gate }def initialize(*args)- if instance_of? LifeCycle+ if instance_of? Project::LifeCycleStepDefinition# Do not allow directly instantiating this class- raise NotImplementedError, "Cannot instantiate the base LifeCycle class directly. " \- "Use Stage or Gate instead."+ raise NotImplementedError, "Cannot instantiate the base Project::LifeCycleStepDefinition class directly. " \+ "Use Project::StageDefinition or Project::GateDefinition instead."endsuperdiff --git a/app/models/project/stage.rb b/app/models/project/stage.rbindex afd6090a067..4e5f8ef92a4 100644--- a/app/models/project/stage.rb+++ b/app/models/project/stage.rb@@ -26,6 +26,6 @@# See COPYRIGHT and LICENSE files for more details.#++-class Project::Stage < Project::LifeCycle+class Project::Stage < Project::LifeCycleStepvalidates :start_date, :end_date, presence: trueenddiff --git a/app/models/gate.rb b/app/models/project/stage_definition.rbsimilarity index 84%rename from app/models/gate.rbrename to app/models/project/stage_definition.rbindex 3eee742ec91..ce9eb4f4d8c 100644--- a/app/models/gate.rb+++ b/app/models/project/stage_definition.rb@@ -26,5 +26,9 @@# See COPYRIGHT and LICENSE files for more details.#++-class Gate < LifeCycle+class Project::StageDefinition < Project::LifeCycleStepDefinition+ has_many :stages, # Alias for life_cycle_steps+ class_name: "Project::Stage",+ foreign_key: :definition_id,+ dependent: :destroyenddiff --git a/app/models/work_package.rb b/app/models/work_package.rbindex c8a2e7a98e7..560f7604448 100644--- a/app/models/work_package.rb+++ b/app/models/work_package.rb@@ -54,7 +54,7 @@ class WorkPackage < ApplicationRecordbelongs_to :assigned_to, class_name: "Principal", optional: truebelongs_to :responsible, class_name: "Principal", optional: truebelongs_to :version, optional: true- belongs_to :project_life_cycle, class_name: "Project::LifeCycle", optional: true+ belongs_to :life_cycle_step, class_name: "Project::LifeCycleStep", optional: truebelongs_to :priority, class_name: "IssuePriority"belongs_to :category, class_name: "Category", optional: truediff --git a/app/seeders/basic_data/life_cycle_seeder.rb b/app/seeders/basic_data/life_cycle_step_definition_seeder.rbsimilarity index 93%rename from app/seeders/basic_data/life_cycle_seeder.rbrename to app/seeders/basic_data/life_cycle_step_definition_seeder.rbindex b60edde765a..54166f73101 100644--- a/app/seeders/basic_data/life_cycle_seeder.rb+++ b/app/seeders/basic_data/life_cycle_step_definition_seeder.rb@@ -26,8 +26,8 @@# See COPYRIGHT and LICENSE files for more details.#++module BasicData- class LifeCycleSeeder < ModelSeeder- self.model_class = LifeCycle+ class LifeCycleStepDefinitionSeeder < ModelSeeder+ self.model_class = Project::LifeCycleStepDefinitionself.seed_data_model_key = "life_cycles"self.needs = [BasicData::LifeCycleColorSeederdiff --git a/app/seeders/standard.yml b/app/seeders/standard.ymlindex 9d81ba64ae4..0e00dea26de 100644--- a/app/seeders/standard.yml+++ b/app/seeders/standard.yml@@ -29,31 +29,31 @@life_cycles:- reference: :default_life_cycle_initiatingt_name: Initiating- type: Stage+ type: Project::StageDefinitioncolor_name: :default_color_pm2_orange- reference: :default_life_cycle_ready_for_planningt_name: Ready for Planning- type: Gate+ type: Project::GateDefinitioncolor_name: :default_color_pm2_purple- reference: :default_life_cycle_planningt_name: Planning- type: Stage+ type: Project::StageDefinitioncolor_name: :default_color_pm2_red- reference: :default_life_cycle_ready_for_executingt_name: Ready for Executing- type: Gate+ type: Project::GateDefinitioncolor_name: :default_color_pm2_purple- reference: :default_life_cycle_executingt_name: Executing- type: Stage+ type: Project::StageDefinitioncolor_name: :default_color_pm2_magenta- reference: :default_life_cycle_ready_for_closingt_name: Ready for Closing- type: Gate+ type: Project::GateDefinitioncolor_name: :default_color_pm2_purple- reference: :default_life_cycle_closingt_name: Closing- type: Stage+ type: Project::StageDefinitioncolor_name: :default_color_pm2_green_yellowpriorities:diff --git a/app/seeders/standard/basic_data_seeder.rb b/app/seeders/standard/basic_data_seeder.rbindex 9d704632867..d77525b74a1 100644--- a/app/seeders/standard/basic_data_seeder.rb+++ b/app/seeders/standard/basic_data_seeder.rb@@ -38,7 +38,7 @@ module Standard::BasicData::ColorSeeder,::BasicData::ColorSchemeSeeder,::BasicData::LifeCycleColorSeeder,- ::BasicData::LifeCycleSeeder,+ ::BasicData::LifeCycleStepDefinitionSeeder,::BasicData::WorkflowSeeder,::BasicData::PrioritySeeder,::BasicData::SettingSeeder,diff --git a/config/locales/en.yml b/config/locales/en.ymlindex b1286e98254..34fec6cbe6f 100644--- a/config/locales/en.yml+++ b/config/locales/en.yml@@ -1071,10 +1071,6 @@ en:name:blank: "is mandatory. Please select a name."not_unique: "is already in use. Please select another name."- life_cycle:- attributes:- type:- must_be_a_stage_or_gate: "must be either Stage or Gate"meeting:error_conflict: "Unable to save because the meeting was updated by someone else in the meantime. Please reload the page."notifications:@@ -1114,14 +1110,18 @@ en:attributes:project_ids:blank: "Please select a project."- project/life_cycle:+ project/life_cycle_step_definition:+ attributes:+ type:+ must_be_a_stage_or_gate: "must be either Project::StageDefinition or Project::GateDefinition"+ project/life_cycle_step:attributes:type:must_be_a_stage_or_gate: "must be either Project::Stage or Project::Gate"project/gate:attributes:base:- end_date_not_allowed: "Cannot assign `end_date` to a Gate"+ end_date_not_allowed: "Cannot assign `end_date` to a Project::Gate"query:attributes:project:diff --git a/db/migrate/20241030154245_create_life_cycles.rb b/db/migrate/20241030154245_create_project_life_cycle_step_definitions.rbsimilarity index 90%rename from db/migrate/20241030154245_create_life_cycles.rbrename to db/migrate/20241030154245_create_project_life_cycle_step_definitions.rbindex 343eea91a4c..79ab5cbd037 100644--- a/db/migrate/20241030154245_create_life_cycles.rb+++ b/db/migrate/20241030154245_create_project_life_cycle_step_definitions.rb@@ -26,9 +26,9 @@# See COPYRIGHT and LICENSE files for more details.#++-class CreateLifeCycles < ActiveRecord::Migration[7.1]+class CreateProjectLifeCycleStepDefinitions < ActiveRecord::Migration[7.1]def change- create_table :life_cycles do |t|+ create_table :project_life_cycle_step_definitions do |t|t.string :typet.string :namet.references :color, foreign_key: truediff --git a/db/migrate/20241105151352_create_project_life_cycles.rb b/db/migrate/20241105151352_create_project_life_cycle_steps.rbsimilarity index 51%rename from db/migrate/20241105151352_create_project_life_cycles.rbrename to db/migrate/20241105151352_create_project_life_cycle_steps.rbindex 847be712c1d..cb4f7553b27 100644--- a/db/migrate/20241105151352_create_project_life_cycles.rb+++ b/db/migrate/20241105151352_create_project_life_cycle_steps.rb@@ -1,12 +1,12 @@-class CreateProjectLifeCycles < ActiveRecord::Migration[7.1]+class CreateProjectLifeCycleSteps < ActiveRecord::Migration[7.1]def change- create_table :project_life_cycles do |t|+ create_table :project_life_cycle_steps do |t|t.string :typet.date :start_datet.date :end_datet.boolean :active, default: false, null: falset.references :project, foreign_key: true- t.references :life_cycle, foreign_key: true+ t.references :definition, foreign_key: { to_table: :project_life_cycle_step_definitions }t.timestampsenddiff --git a/db/migrate/20241105175000_add_life_cycle_to_work_packages.rb b/db/migrate/20241105175000_add_life_cycle_to_work_packages.rbindex 3d24434d617..eb8081aed5f 100644--- a/db/migrate/20241105175000_add_life_cycle_to_work_packages.rb+++ b/db/migrate/20241105175000_add_life_cycle_to_work_packages.rb@@ -1,5 +1,8 @@class AddLifeCycleToWorkPackages < ActiveRecord::Migration[7.1]def change- add_reference :work_packages, :project_life_cycle, foreign_key: true, null: true+ add_reference :work_packages,+ :life_cycle_step,+ foreign_key: { to_table: :project_life_cycle_steps },+ null: trueendenddiff --git a/modules/bim/app/seeders/bim/basic_data_seeder.rb b/modules/bim/app/seeders/bim/basic_data_seeder.rbindex b1e38770a8a..d153b2e4227 100644--- a/modules/bim/app/seeders/bim/basic_data_seeder.rb+++ b/modules/bim/app/seeders/bim/basic_data_seeder.rb@@ -38,7 +38,7 @@ module Bim::BasicData::ColorSeeder,::BasicData::ColorSchemeSeeder,::BasicData::LifeCycleColorSeeder,- ::BasicData::LifeCycleSeeder,+ ::BasicData::LifeCycleStepDefinitionSeeder,::BasicData::WorkflowSeeder,::BasicData::PrioritySeeder,::Bim::BasicData::SettingSeeder,diff --git a/spec/factories/life_cycle_factory.rb b/spec/factories/project_life_cycle_step_definition_factory.rbsimilarity index 77%rename from spec/factories/life_cycle_factory.rbrename to spec/factories/project_life_cycle_step_definition_factory.rbindex 81752900bf8..f629dcb4018 100644--- a/spec/factories/life_cycle_factory.rb+++ b/spec/factories/project_life_cycle_step_definition_factory.rb@@ -27,15 +27,15 @@#++FactoryBot.define do- factory :life_cycle do+ factory :project_life_cycle_step_definition, class: "Project::LifeCycleStepDefinition" docolor- factory :gate, class: "Gate" do- sequence(:name) { |n| "Gate No. #{n}" }+ factory :project_gate_definition, class: "Project::GateDefinition" do+ sequence(:name) { |n| "Gate Definition No. #{n}" }end- factory :stage, class: "Stage" do- sequence(:name) { |n| "Stage No. #{n}" }+ factory :project_stage_definition, class: "Project::StageDefinition" do+ sequence(:name) { |n| "Stage Definition No. #{n}" }endendenddiff --git a/spec/factories/project_life_cycle_factory.rb b/spec/factories/project_life_cycle_step_factory.rbsimilarity index 89%rename from spec/factories/project_life_cycle_factory.rbrename to spec/factories/project_life_cycle_step_factory.rbindex 72eaf33563d..cc64e09b02e 100644--- a/spec/factories/project_life_cycle_factory.rb+++ b/spec/factories/project_life_cycle_step_factory.rb@@ -27,18 +27,18 @@#++FactoryBot.define do- factory :project_life_cycle, class: "Project::LifeCycle" do+ factory :project_life_cycle_step, class: "Project::LifeCycleStep" doprojectactive { true }factory :project_stage, class: "Project::Stage" do- life_cycle factory: :stage+ definition factory: :project_stage_definitionstart_date { Date.current - 2.days }end_date { Date.current + 2.days }endfactory :project_gate, class: "Project::Gate" do- life_cycle factory: :gate+ definition factory: :project_gate_definitiondate { Date.current + 2.days }endenddiff --git a/spec/models/stage_spec.rb b/spec/models/project/gate_definition_spec.rbsimilarity index 88%rename from spec/models/stage_spec.rbrename to spec/models/project/gate_definition_spec.rbindex 750ba837927..e1bc2f1cb0f 100644--- a/spec/models/stage_spec.rb+++ b/spec/models/project/gate_definition_spec.rb@@ -27,8 +27,8 @@#++require "rails_helper"-require "support/shared/life_cycle_helpers"+require "support/shared/project_life_cycle_helpers"-RSpec.describe Stage do- it_behaves_like "a LifeCycle event"+RSpec.describe Project::GateDefinition do+ it_behaves_like "a Project::LifeCycleStepDefinition event"enddiff --git a/spec/models/project/gate_spec.rb b/spec/models/project/gate_spec.rbindex 49a594e78e1..874a4314ee0 100644--- a/spec/models/project/gate_spec.rb+++ b/spec/models/project/gate_spec.rb@@ -30,7 +30,7 @@ require "rails_helper"require "support/shared/project_life_cycle_helpers"RSpec.describe Project::Gate do- it_behaves_like "a Project::LifeCycle event"+ it_behaves_like "a Project::LifeCycleStep event"describe "validations" doit { is_expected.to validate_presence_of(:date) }@@ -39,7 +39,8 @@ RSpec.describe Project::Gate 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 `end_date` to a Gate")+ expect(gate_with_end_date.errors[:base])+ .to include("Cannot assign `end_date` to a Project::Gate")endit "is valid if `end_date` is not present" dodiff --git a/spec/models/life_cycle_spec.rb b/spec/models/project/life_cycle_step_definition_spec.rbsimilarity index 86%rename from spec/models/life_cycle_spec.rbrename to spec/models/project/life_cycle_step_definition_spec.rbindex 1c671f05a3f..7ccdf639978 100644--- a/spec/models/life_cycle_spec.rb+++ b/spec/models/project/life_cycle_step_definition_spec.rb@@ -28,13 +28,13 @@require "rails_helper"-RSpec.describe LifeCycle do+RSpec.describe Project::LifeCycleStepDefinition doit "cannot be instantiated" doexpect { described_class.new }.to raise_error(NotImplementedError)end# For more specs see:- # - spec/support/shared/life_cycle_helpers.rb- # - spec/models/gate_spec.rb- # - spec/models/stage_spec.rb+ # - spec/support/shared/project_life_cycle_helpers.rb+ # - spec/models/project/gate_definition_spec.rb+ # - spec/models/project/stage_definition_spec.rbenddiff --git a/spec/models/project/life_cycle_spec.rb b/spec/models/project/life_cycle_step_spec.rbsimilarity index 93%rename from spec/models/project/life_cycle_spec.rbrename to spec/models/project/life_cycle_step_spec.rbindex be54b48bfbe..1c47422612d 100644--- a/spec/models/project/life_cycle_spec.rb+++ b/spec/models/project/life_cycle_step_spec.rb@@ -28,7 +28,7 @@require "rails_helper"-RSpec.describe Project::LifeCycle do+RSpec.describe Project::LifeCycleStep doit "cannot be instantiated" doexpect { described_class.new }.to raise_error(NotImplementedError)end@@ -36,7 +36,7 @@ RSpec.describe Project::LifeCycle dodescribe "with an instantiated Gate" dosubject { build :project_gate }- it { is_expected.to have_readonly_attribute(:life_cycle_id) }+ it { is_expected.to have_readonly_attribute(:definition_id) }end# For more specs see:diff --git a/spec/models/gate_spec.rb b/spec/models/project/stage_definition_spec.rbsimilarity index 88%rename from spec/models/gate_spec.rbrename to spec/models/project/stage_definition_spec.rbindex bed01deef3f..b4e223f5fdf 100644--- a/spec/models/gate_spec.rb+++ b/spec/models/project/stage_definition_spec.rb@@ -27,8 +27,8 @@#++require "rails_helper"-require "support/shared/life_cycle_helpers"+require "support/shared/project_life_cycle_helpers"-RSpec.describe Gate do- it_behaves_like "a LifeCycle event"+RSpec.describe Project::StageDefinition do+ it_behaves_like "a Project::LifeCycleStepDefinition event"enddiff --git a/spec/models/project/stage_spec.rb b/spec/models/project/stage_spec.rbindex 35b8231ed08..2ee72a827ed 100644--- a/spec/models/project/stage_spec.rb+++ b/spec/models/project/stage_spec.rb@@ -30,7 +30,7 @@ require "rails_helper"require "support/shared/project_life_cycle_helpers"RSpec.describe Project::Stage do- it_behaves_like "a Project::LifeCycle event"+ it_behaves_like "a Project::LifeCycleStep event"describe "validations" doit { is_expected.to validate_presence_of(:start_date) }diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rbindex 57cce3c2cce..2f191a053f3 100644--- a/spec/models/project_spec.rb+++ b/spec/models/project_spec.rb@@ -382,7 +382,7 @@ RSpec.describe Project doenddescribe "life_cycles" do- it { is_expected.to have_many(:project_life_cycles).class_name("Project::LifeCycle").dependent(:destroy) }+ it { is_expected.to have_many(:life_cycle_steps).class_name("Project::LifeCycleStep").dependent(:destroy) }enddescribe "#enabled_module_names=", with_settings: { default_projects_modules: %w(work_package_tracking repository) } dodiff --git a/spec/models/work_package_spec.rb b/spec/models/work_package_spec.rbindex f7feedf0786..cabd9fc3808 100644--- a/spec/models/work_package_spec.rb+++ b/spec/models/work_package_spec.rb@@ -70,7 +70,7 @@ RSpec.describe WorkPackage doit { is_expected.to belong_to(:assigned_to).class_name("Principal").optional }it { is_expected.to belong_to(:responsible).class_name("Principal").optional }it { is_expected.to belong_to(:version).optional }- it { is_expected.to belong_to(:project_life_cycle).class_name("Project::LifeCycle").optional }+ it { is_expected.to belong_to(:life_cycle_step).class_name("Project::LifeCycleStep").optional }it { is_expected.to belong_to(:priority).class_name("IssuePriority") }it { is_expected.to belong_to(:category).optional }it { is_expected.to have_many(:time_entries).dependent(:delete_all) }diff --git a/spec/seeders/basic_data/life_cycle_color_seeder_spec.rb b/spec/seeders/basic_data/life_cycle_color_seeder_spec.rbindex 459f30ed534..c63c2d62525 100644--- a/spec/seeders/basic_data/life_cycle_color_seeder_spec.rb+++ b/spec/seeders/basic_data/life_cycle_color_seeder_spec.rb@@ -123,7 +123,11 @@ RSpec.describe BasicData::LifeCycleColorSeeder doendit "creates no life cycle colors" do- expect(LifeCycle.count).to eq(0)+ expect(Color.find_by(name: "PM2 Orange")).to be_nil+ expect(Color.find_by(name: "PM2 Red")).to be_nil+ expect(Color.find_by(name: "PM2 Purple")).to be_nil+ expect(Color.find_by(name: "PM2 Magenta")).to be_nil+ expect(Color.find_by(name: "PM2 Green Yellow")).to be_nilendendenddiff --git a/spec/seeders/basic_data/life_cycle_seeder_spec.rb b/spec/seeders/basic_data/life_cycle_step_definition_seeder_spec.rbsimilarity index 82%rename from spec/seeders/basic_data/life_cycle_seeder_spec.rbrename to spec/seeders/basic_data/life_cycle_step_definition_seeder_spec.rbindex 8240abd63e7..367f1fdcc5a 100644--- a/spec/seeders/basic_data/life_cycle_seeder_spec.rb+++ b/spec/seeders/basic_data/life_cycle_step_definition_seeder_spec.rb@@ -30,7 +30,7 @@require "spec_helper"-RSpec.describe BasicData::LifeCycleSeeder do+RSpec.describe BasicData::LifeCycleStepDefinitionSeeder doinclude_context "with basic seed data"subject(:seeder) { described_class.new(seed_data) }@@ -46,49 +46,49 @@ RSpec.describe BasicData::LifeCycleSeeder dolife_cycles:- reference: :default_life_cycle_initiatingname: Initiating- type: Stage+ type: Project::StageDefinitioncolor_name: :default_color_pm2_orange- reference: :default_life_cycle_ready_for_executingname: Ready for Executing- type: Gate+ type: Project::GateDefinitioncolor_name: :default_color_pm2_purple- reference: :default_life_cycle_planningname: Planning- type: Stage+ type: Project::StageDefinitioncolor_name: :default_color_pm2_red- reference: :default_life_cycle_executingname: Executing- type: Stage+ type: Project::StageDefinitioncolor_name: :default_color_pm2_magenta- reference: :default_life_cycle_closingname: Closing- type: Stage+ type: Project::StageDefinitioncolor_name: :default_color_pm2_green_yellowSEEDING_DATA_YAMLendit "creates the corresponding life cycles with the given attributes" do- expect(LifeCycle.count).to eq(5)- expect(Stage.find_by(name: "Initiating")).to have_attributes(+ expect(Project::LifeCycleStepDefinition.count).to eq(5)+ expect(Project::StageDefinition.find_by(name: "Initiating")).to have_attributes(color: have_attributes(name: "PM2 Orange"))- expect(Gate.find_by(name: "Ready for Executing")).to have_attributes(+ expect(Project::GateDefinition.find_by(name: "Ready for Executing")).to have_attributes(color: have_attributes(name: "PM2 Purple"))- expect(Stage.find_by(name: "Planning")).to have_attributes(+ expect(Project::StageDefinition.find_by(name: "Planning")).to have_attributes(color: have_attributes(name: "PM2 Red"))- expect(Stage.find_by(name: "Executing")).to have_attributes(+ expect(Project::StageDefinition.find_by(name: "Executing")).to have_attributes(color: have_attributes(name: "PM2 Magenta"))- expect(Stage.find_by(name: "Closing")).to have_attributes(+ expect(Project::StageDefinition.find_by(name: "Closing")).to have_attributes(color: have_attributes(name: "PM2 Green Yellow"))endit "references the life cycles in the seed data" do- Stage.find_each do |expected_stage|- reference = :"default_life_cycle_#{expected_stage.name.downcase}"+ Project::LifeCycleStepDefinition.find_each do |expected_stage|+ reference = :"default_life_cycle_#{expected_stage.name.downcase.gsub(/\s+/, '_')}"expect(seed_data.find_reference(reference)).to eq(expected_stage)endend@@ -126,7 +126,7 @@ RSpec.describe BasicData::LifeCycleSeeder doendit "creates no life cycles" do- expect(LifeCycle.count).to eq(0)+ expect(Project::LifeCycleStepDefinition.count).to eq(0)endendenddiff --git a/spec/support/shared/life_cycle_helpers.rb b/spec/support/shared/life_cycle_helpers.rbdeleted file mode 100644index ba363537661..00000000000--- a/spec/support/shared/life_cycle_helpers.rb+++ /dev/null@@ -1,50 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++--RSpec.shared_examples_for "a LifeCycle event" do- it "inherits from LifeCycle" do- expect(described_class).to be < LifeCycle- end-- describe "associations" do- it { is_expected.to have_many(:project_life_cycles).dependent(:destroy) }- it { is_expected.to have_many(:projects).through(:project_life_cycles) }- it { is_expected.to belong_to(:color).required }- end-- describe "validations" do- it { is_expected.to validate_presence_of(:name) }-- it "is invalid if type is not Stage or Gate" do- life_cycle = described_class.new- life_cycle.type = "InvalidType"- expect(life_cycle).not_to be_valid- expect(life_cycle.errors[:type]).to include("must be either Stage or Gate")- end- end-enddiff --git a/spec/support/shared/project_life_cycle_helpers.rb b/spec/support/shared/project_life_cycle_helpers.rbindex 7fd60a45a46..9dff4aa8792 100644--- a/spec/support/shared/project_life_cycle_helpers.rb+++ b/spec/support/shared/project_life_cycle_helpers.rb@@ -26,19 +26,43 @@# See COPYRIGHT and LICENSE files for more details.#++-RSpec.shared_examples_for "a Project::LifeCycle event" do- it "inherits from Project::LifeCycle" do- expect(described_class).to be < Project::LifeCycle+RSpec.shared_examples_for "a Project::LifeCycleStepDefinition event" do+ it "inherits from LifeCycleStepDefinition" do+ expect(described_class).to be < Project::LifeCycleStepDefinition+ end++ describe "associations" do+ it { is_expected.to have_many(:life_cycle_steps).dependent(:destroy) }+ it { is_expected.to have_many(:projects).through(:life_cycle_steps) }+ it { is_expected.to belong_to(:color).required }+ end++ describe "validations" do+ it { is_expected.to validate_presence_of(:name) }++ it "is invalid if type is not Project::StageDefinition or Project::GateDefinition" do+ life_cycle = described_class.new+ life_cycle.type = "InvalidType"+ expect(life_cycle).not_to be_valid+ expect(life_cycle.errors[:type])+ .to include("must be either Project::StageDefinition or Project::GateDefinition")+ end+ end+end++RSpec.shared_examples_for "a Project::LifeCycleStep event" do+ it "inherits from Project::LifeCycleStep" do+ expect(described_class).to be < Project::LifeCycleStependdescribe "associations" doit { is_expected.to belong_to(:project).required }- it { is_expected.to belong_to(:life_cycle).required }+ it { is_expected.to belong_to(:definition).required }it { is_expected.to have_many(:work_packages) }enddescribe "validations" do- it "is invalid if type is not Stage or Gate" do+ it "is invalid if type is not Project::Stage or Project::Gate" dolife_cycle = described_class.newlife_cycle.type = "InvalidType"expect(life_cycle).not_to be_valid