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
Use ::Project namespace for LifeCycle, Stage and Gate
Dombi Attila7f458c71f6ac
diff --git a/app/models/life_cycle.rb b/app/models/life_cycle.rbindex 5744a30b914..ec88b5ff43c 100644--- a/app/models/life_cycle.rb+++ b/app/models/life_cycle.rb@@ -27,7 +27,7 @@#++class LifeCycle < ApplicationRecord- has_many :project_life_cycles, dependent: :destroy+ has_many :project_life_cycles, class_name: "Project::LifeCycle", dependent: :destroyhas_many :projects, through: :project_life_cyclesbelongs_to :color, optional: falsediff --git a/app/models/project.rb b/app/models/project.rbindex 0ce2162dcdd..0893018a0ba 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, dependent: :destroy+ has_many :project_life_cycles, class_name: "Project::LifeCycle", dependent: :destroyhas_many :life_cycles, through: :project_life_cyclesstore_attribute :settings, :deactivate_work_package_attachments, :booleandiff --git a/app/models/projects/gate.rb b/app/models/project/gate.rbsimilarity index 97%rename from app/models/projects/gate.rbrename to app/models/project/gate.rbindex 9559b4c115c..1aef0ec5464 100644--- a/app/models/projects/gate.rb+++ b/app/models/project/gate.rb@@ -26,7 +26,7 @@# See COPYRIGHT and LICENSE files for more details.#++-class Projects::Gate < ProjectLifeCycle+class Project::Gate < Project::LifeCyclevalidates :date, presence: truevalidate :validate_restricted_attributesdiff --git a/app/models/project_life_cycle.rb b/app/models/project/life_cycle.rbsimilarity index 78%rename from app/models/project_life_cycle.rbrename to app/models/project/life_cycle.rbindex 74fa6df3f00..377dbe00e09 100644--- a/app/models/project_life_cycle.rb+++ b/app/models/project/life_cycle.rb@@ -26,18 +26,18 @@# See COPYRIGHT and LICENSE files for more details.#++-class ProjectLifeCycle < ApplicationRecord+class Project::LifeCycle < ApplicationRecordbelongs_to :project, optional: falsebelongs_to :life_cycle, optional: false- has_many :work_packages, dependent: :nullify+ has_many :work_packages, foreign_key: :project_life_cycle_id, dependent: :nullify- validates :type, inclusion: { in: %w[Projects::Stage Projects::Gate], message: :must_be_a_stage_or_gate }+ validates :type, inclusion: { in: %w[Project::Stage Project::Gate], message: :must_be_a_stage_or_gate }def initialize(*args)- if instance_of? ProjectLifeCycle+ if instance_of? Project::LifeCycle# Do not allow directly instantiating this class- raise NotImplementedError, "Cannot instantiate the base ProjectLifeCycle class directly. " \- "Use Projects::Stage or Projects::Gate instead."+ raise NotImplementedError, "Cannot instantiate the base Project::LifeCycle class directly. " \+ "Use Project::Stage or Project::Gate instead."endsuperdiff --git a/app/models/projects/stage.rb b/app/models/project/stage.rbsimilarity index 97%rename from app/models/projects/stage.rbrename to app/models/project/stage.rbindex 0532653795c..31a82be13ff 100644--- a/app/models/projects/stage.rb+++ b/app/models/project/stage.rb@@ -26,7 +26,7 @@# See COPYRIGHT and LICENSE files for more details.#++-class Projects::Stage < ProjectLifeCycle+class Project::Stage < Project::LifeCyclevalidates :start_date, :end_date, presence: truevalidate :validate_restricted_attributesdiff --git a/app/models/work_package.rb b/app/models/work_package.rbindex 9f5c2f2c046..c8a2e7a98e7 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, optional: true+ belongs_to :project_life_cycle, class_name: "Project::LifeCycle", optional: truebelongs_to :priority, class_name: "IssuePriority"belongs_to :category, class_name: "Category", optional: truediff --git a/config/locales/en.yml b/config/locales/en.ymlindex c02f52111cd..2644d868e04 100644--- a/config/locales/en.yml+++ b/config/locales/en.yml@@ -1110,15 +1110,15 @@ en:attributes:project_ids:blank: "Please select a project."- project_life_cycle:+ project/life_cycle:attributes:type:must_be_a_stage_or_gate: "must be either Stage or Gate"- projects/gate:+ project/gate:attributes:base:date_range_not_allowed: "Cannot assign `start_date` or `end_date` to a Gate"- projects/stage:+ project/stage:attributes:base:date_not_allowed: "Cannot assign `date` to a Stage"diff --git a/spec/factories/project_life_cycle_factory.rb b/spec/factories/project_life_cycle_factory.rbindex abe1ce59cf6..f96a7c160ac 100644--- a/spec/factories/project_life_cycle_factory.rb+++ b/spec/factories/project_life_cycle_factory.rb@@ -27,16 +27,16 @@#++FactoryBot.define do- factory :project_life_cycle do+ factory :project_life_cycle, class: "Project::LifeCycle" doprojectlife_cycle- factory :project_stage, class: "::Projects::Stage" do+ factory :project_stage, class: "Project::Stage" dostart_date { Date.current - 2.days }end_date { Date.current + 2.days }end- factory :project_gate, class: "::Projects::Gate" do+ factory :project_gate, class: "Project::Gate" dodate { Date.current + 2.days }endenddiff --git a/spec/models/projects/life_cycle_spec.rb b/spec/models/life_cycle_spec.rbsimilarity index 100%rename from spec/models/projects/life_cycle_spec.rbrename to spec/models/life_cycle_spec.rbdiff --git a/spec/models/projects/gate_spec.rb b/spec/models/project/gate_spec.rbsimilarity index 96%rename from spec/models/projects/gate_spec.rbrename to spec/models/project/gate_spec.rbindex 333c9b0ee29..b4408cd86bc 100644--- a/spec/models/projects/gate_spec.rb+++ b/spec/models/project/gate_spec.rb@@ -29,8 +29,8 @@require "rails_helper"require "support/shared/project_life_cycle_helpers"-RSpec.describe Projects::Gate do- it_behaves_like "a ProjectLifeCycle event"+RSpec.describe Project::Gate do+ it_behaves_like "a Project::LifeCycle event"describe "validations" doit { is_expected.to validate_presence_of(:date) }diff --git a/spec/models/project_life_cycle_spec.rb b/spec/models/project/life_cycle_spec.rbsimilarity index 93%rename from spec/models/project_life_cycle_spec.rbrename to spec/models/project/life_cycle_spec.rbindex 13b636699f9..48de1751bf3 100644--- a/spec/models/project_life_cycle_spec.rb+++ b/spec/models/project/life_cycle_spec.rb@@ -28,7 +28,7 @@require "rails_helper"-RSpec.describe ProjectLifeCycle do+RSpec.describe Project::LifeCycle doit "cannot be instantiated" doexpect { described_class.new }.to raise_error(NotImplementedError)end@@ -38,7 +38,7 @@ RSpec.describe ProjectLifeCycle doendit "can be instantiated with a valid type" do- expect { described_class.new(type: "Projects::Gate") }.not_to raise_error+ expect { described_class.new(type: "Project::Gate") }.not_to raise_errorend# For more specs see:diff --git a/spec/models/projects/stage_spec.rb b/spec/models/project/stage_spec.rbsimilarity index 95%rename from spec/models/projects/stage_spec.rbrename to spec/models/project/stage_spec.rbindex d3c988a4a4d..6e2ac4f2ee6 100644--- a/spec/models/projects/stage_spec.rb+++ b/spec/models/project/stage_spec.rb@@ -29,8 +29,8 @@require "rails_helper"require "support/shared/project_life_cycle_helpers"-RSpec.describe Projects::Stage do- it_behaves_like "a ProjectLifeCycle event"+RSpec.describe Project::Stage do+ it_behaves_like "a Project::LifeCycle 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 e168340094a..01e21868959 100644--- a/spec/models/project_spec.rb+++ b/spec/models/project_spec.rb@@ -382,14 +382,8 @@ RSpec.describe Project doenddescribe "life_cycles" do- it { is_expected.to have_many(:project_life_cycles).dependent(:destroy) }-- it do- expect(subject)- .to have_many(:life_cycles)- .through(:project_life_cycles)- .class_name("Projects::LifeCycle")- end+ it { 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) } dodiff --git a/spec/models/work_package_spec.rb b/spec/models/work_package_spec.rbindex 7c247ab052a..f7feedf0786 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(:life_cycle).optional }+ it { is_expected.to belong_to(:project_life_cycle).class_name("Project::LifeCycle").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/support/shared/project_life_cycle_helpers.rb b/spec/support/shared/project_life_cycle_helpers.rbindex 9201b7416ec..2a657268c03 100644--- a/spec/support/shared/project_life_cycle_helpers.rb+++ b/spec/support/shared/project_life_cycle_helpers.rb@@ -26,9 +26,9 @@# See COPYRIGHT and LICENSE files for more details.#++-RSpec.shared_examples_for "a ProjectLifeCycle event" do- it "inherits from ProjectLifeCycle" do- expect(described_class < ProjectLifeCycle).to be true+RSpec.shared_examples_for "a Project::LifeCycle event" do+ it "inherits from Project::LifeCycle" do+ expect(described_class < Project::LifeCycle).to be trueenddescribe "associations" do