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
show phase definition linked to work package
ulfertsa18ef2811891
diff --git a/app/contracts/work_packages/base_contract.rb b/app/contracts/work_packages/base_contract.rbindex a6561859f9c..48f9018d609 100644--- a/app/contracts/work_packages/base_contract.rb+++ b/app/contracts/work_packages/base_contract.rb@@ -82,6 +82,9 @@ module WorkPackagesattribute :parent_id,permission: :manage_subtasks+ attribute :project_phase_definition_id,+ permission: :edit_project_phases+attribute :assigned_to_id donext unless model.projectdiff --git a/app/models/work_package.rb b/app/models/work_package.rbindex 62c0cd9b7db..d7b2f786923 100644--- a/app/models/work_package.rb+++ b/app/models/work_package.rb@@ -55,7 +55,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_phase, class_name: "Project::Phase", optional: true+ belongs_to :project_phase_definition, class_name: "Project::PhaseDefinition", 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 ff08a3c0e11..a0641dadc94 100644--- a/config/locales/en.yml+++ b/config/locales/en.yml@@ -1707,6 +1707,8 @@ en:priority: "Priority"project: "Project"project_ids: "Project IDs"+ project_phase: "Project phase"+ project_phase_definition: "Project phase"reason: "Reason"responsible: "Accountable"required: "Required"diff --git a/db/migrate/20250403150639_link_wp_to_project_phase_definition.rb b/db/migrate/20250403150639_link_wp_to_project_phase_definition.rbnew file mode 100644index 00000000000..04271fbcda4--- /dev/null+++ b/db/migrate/20250403150639_link_wp_to_project_phase_definition.rb@@ -0,0 +1,42 @@+# frozen_string_literal: true++# -- 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.+# ++++class LinkWpToProjectPhaseDefinition < ActiveRecord::Migration[8.0]+ def change+ change_table :work_packages do |t|+ t.remove_references :project_phase, null: true+ t.references :project_phase_definition, null: true, index: true+ end++ change_table :work_package_journals do |t|+ t.column :project_phase_definition_id, :bigint, null: true+ end+ end+enddiff --git a/frontend/src/app/shared/components/fields/display/display-field.initializer.ts b/frontend/src/app/shared/components/fields/display/display-field.initializer.tsindex 9c9b317c9f2..e23f28ca92e 100644--- a/frontend/src/app/shared/components/fields/display/display-field.initializer.ts+++ b/frontend/src/app/shared/components/fields/display/display-field.initializer.ts@@ -101,6 +101,7 @@ export function initializeCoreDisplayFields(displayFieldService:DisplayFieldServ.addFieldType(TypeDisplayField, 'type', ['Type']).addFieldType(ResourceDisplayField, 'resource', ['Project',+ 'ProjectPhaseDefinition','TimeEntriesActivity','Version','Category',diff --git a/lib/api/v3/project_phase_definitions/project_phase_definition_representer.rb b/lib/api/v3/project_phase_definitions/project_phase_definition_representer.rbnew file mode 100644index 00000000000..4b8adced1bb--- /dev/null+++ b/lib/api/v3/project_phase_definitions/project_phase_definition_representer.rb@@ -0,0 +1,55 @@+# frozen_string_literal: true++# -- 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.+# ++++module API+ module V3+ module ProjectPhaseDefinitions+ class ProjectPhaseDefinitionRepresenter < ::API::Decorators::Single+ include API::Decorators::DateProperty++ self_link++ property :id+ property :name+ property :start_gate+ property :start_gate_name, render_nil: true+ property :finish_gate+ property :finish_gate_name, render_nil: true++ date_time_property :created_at+ date_time_property :updated_at++ def _type+ "ProjectPhaseDefinition"+ end+ end+ end+ end+enddiff --git a/lib/api/v3/utilities/path_helper.rb b/lib/api/v3/utilities/path_helper.rbindex ec04d1085fe..b5c05421278 100644--- a/lib/api/v3/utilities/path_helper.rb+++ b/lib/api/v3/utilities/path_helper.rb@@ -327,6 +327,8 @@ module APIresources :project+ show :project_phase_definition+show :project_statusdef self.projects_available_parents@@ -547,7 +549,7 @@ module APIresources :work_package, except: :schemadef self.work_package(id, timestamps: nil)- "#{root}/work_packages/#{id}" + \+ "#{root}/work_packages/#{id}" +if (param_value = timestamps_to_param_value(timestamps)).present? && Array(timestamps).any?(&:historic?)"?#{{ timestamps: param_value }.to_query}"end.to_sdiff --git a/lib/api/v3/work_packages/schema/work_package_schema_representer.rb b/lib/api/v3/work_packages/schema/work_package_schema_representer.rbindex b4c68d43fdb..cec3a807c6a 100644--- a/lib/api/v3/work_packages/schema/work_package_schema_representer.rb+++ b/lib/api/v3/work_packages/schema/work_package_schema_representer.rb@@ -26,9 +26,6 @@# See COPYRIGHT and LICENSE files for more details.#++-require "roar/decorator"-require "roar/json/hal"-module APImodule V3module WorkPackages@@ -84,7 +81,7 @@ module APIdef initialize(schema, self_link:, **context)@base_schema_link = context.delete(:base_schema_link) || nil@show_lock_version = !context.delete(:hide_lock_version)- super(schema, self_link:, **context)+ superendlink :baseSchema do@@ -93,6 +90,7 @@ module APIlink :attachments donext if represented.work_package.hide_attachments?+{ href: nil }end@@ -228,6 +226,13 @@ module APIend}+ # TODO: Turn into schema_with_allowed_link+ schema :project_phase_definition,+ type: "ProjectPhaseDefinition",+ location: :link,+ required: false,+ name_source: :project_phase+schema_with_allowed_link :parent,type: "WorkPackage",required: false,diff --git a/lib/api/v3/work_packages/work_package_representer.rb b/lib/api/v3/work_packages/work_package_representer.rbindex 12b3340d608..2be5645ef6a 100644--- a/lib/api/v3/work_packages/work_package_representer.rb+++ b/lib/api/v3/work_packages/work_package_representer.rb@@ -487,6 +487,31 @@ module APIassociated_resource :project+ resource :project_phase_definition,+ link_cache_if: -> { view_project_phase_allowed? },+ link: ->(*) {+ if phase_set_and_active?+ {+ href: api_v3_paths.project_phase_definition(represented.project_phase_definition_id),+ title: represented.project_phase_definition.name+ }+ else+ {+ href: nil,+ title: nil+ }+ end+ },+ getter: ->(*) do+ if embed_links && phase_set_and_active? && view_project_phase_allowed?+ API::V3::ProjectPhaseDefinitions::ProjectPhaseDefinitionRepresenter.create(+ represented.project_phase_definition, current_user:+ )+ end+ end,+ # TODO: write the setter+ setter: ->(*) {}+associated_resource :statusassociated_resource :author,@@ -630,6 +655,10 @@ module API@view_budgets_allowed ||= current_user.allowed_in_project?(:view_budgets, represented.project)end+ def view_project_phase_allowed?+ @view_project_phase_allowed ||= current_user.allowed_in_project?(:view_project_phases, represented.project)+ end+def export_work_packages_allowed?@export_work_packages_allowed ||=current_user.allowed_in_work_package?(:export_work_packages, represented)@@ -640,6 +669,12 @@ module APIcurrent_user.allowed_in_project?(:add_work_packages, represented.project)end+ def phase_set_and_active?+ represented.project&.phases&.any? do+ it.definition_id == represented.project_phase_definition_id && it.active?+ end+ end+def relationsself_path = api_v3_paths.work_package_relations(represented.id)visible_relations = representeddiff --git a/spec/features/work_packages/project_phases/linking_spec.rb b/spec/features/work_packages/project_phases/linking_spec.rbnew file mode 100644index 00000000000..52e3dfb5477--- /dev/null+++ b/spec/features/work_packages/project_phases/linking_spec.rb@@ -0,0 +1,59 @@+# frozen_string_literal: true++# -- 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.+# ++++require "spec_helper"++RSpec.describe "Linking Projects phases and work packages settings", :js, with_flag: { stages_and_gates: true } do+ shared_let(:initiating_phase_definition) { create(:project_phase_definition, name: "Initiating") }+ shared_let(:executing_phase_definition) do+ create(:project_phase_definition, name: "Executing", start_gate: true, start_gate_name: "Ready to Execute")+ end+ shared_let(:project) { create(:project) }+ shared_let(:initiating_phase) { create(:project_phase, project: project, definition: initiating_phase_definition) }+ shared_let(:executing_phase) { create(:project_phase, project: project, definition: executing_phase_definition) }+ shared_let(:work_package) do+ create(:work_package,+ project:,+ project_phase_definition: executing_phase_definition)+ end+ shared_let(:user) do+ create(:user,+ member_with_permissions: { project => %i[view_project_phases view_work_packages edit_work_packages] })+ end+ current_user { user }++ let(:work_package_page) { Pages::FullWorkPackage.new(work_package) }++ it "allows seeing linked phases" do+ work_package_page.visit!++ work_package_page.expect_attributes(project_phase_definition: executing_phase_definition.name)+ end+enddiff --git a/spec/lib/api/v3/project_phase_definitions/project_phase_definition_representer_spec.rb b/spec/lib/api/v3/project_phase_definitions/project_phase_definition_representer_spec.rbnew file mode 100644index 00000000000..6cc992ae808--- /dev/null+++ b/spec/lib/api/v3/project_phase_definitions/project_phase_definition_representer_spec.rb@@ -0,0 +1,97 @@+# frozen_string_literal: true++# -- 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.+# ++++require "spec_helper"++RSpec.describe API::V3::ProjectPhaseDefinitions::ProjectPhaseDefinitionRepresenter, "rendering" do+ include API::V3::Utilities::PathHelper++ let(:current_user) { build_stubbed(:user) }+ let(:definition) { build_stubbed(:project_phase_definition, :with_gates) }+ let(:representer) do+ described_class.create(definition, current_user:, embed_links: true)+ end++ subject { representer.to_json }++ describe "_links" do+ describe "self" do+ it_behaves_like "has a titled link" do+ let(:link) { "self" }+ let(:href) { api_v3_paths.project_phase_definition definition.id }+ let(:title) { definition.name }+ end+ end+ end++ describe "properties" do+ it_behaves_like "property", :_type do+ let(:value) { "ProjectPhaseDefinition" }+ end++ it_behaves_like "property", :id do+ let(:value) { definition.id }+ end++ it_behaves_like "property", :name do+ let(:value) { definition.name }+ end++ it_behaves_like "property", :startGate do+ let(:value) { definition.start_gate? }+ end++ it_behaves_like "property", :startGateName do+ let(:value) { definition.start_gate_name }+ end++ it_behaves_like "property", :finishGate do+ let(:value) { definition.finish_gate? }+ end++ it_behaves_like "property", :finishGateName do+ let(:value) { definition.finish_gate_name }+ end++ describe "createdAt" do+ it_behaves_like "has UTC ISO 8601 date and time" do+ let(:date) { definition.created_at }+ let(:json_path) { "createdAt" }+ end+ end++ describe "updatedAt" do+ it_behaves_like "has UTC ISO 8601 date and time" do+ let(:date) { definition.updated_at }+ let(:json_path) { "updatedAt" }+ end+ end+ end+enddiff --git a/spec/lib/api/v3/support/embedded_examples.rb b/spec/lib/api/v3/support/embedded_examples.rbnew file mode 100644index 00000000000..d7a6f60a899--- /dev/null+++ b/spec/lib/api/v3/support/embedded_examples.rb@@ -0,0 +1,88 @@+# frozen_string_literal: true++# -- 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 "has the resource embedded" do+ let(:embedded_path) do+ super()+ rescue NoMethodError+ raise "'embedded_path' not defined in a let block"+ end+ let(:embedded_resource) do+ super()+ rescue NoMethodError+ raise "'resource' not defined in a let block. Alternatively, you can define 'resource_name' in a let block."+ end+ let(:embedded_resource_name) do+ super()+ rescue NoMethodError+ embedded_resource.name+ end+ let(:embedded_resource_type) do+ super()+ rescue NoMethodError+ embedded_resource.class.name+ end++ context "when resources are embedded" do+ let(:embed_links) { true }++ it "has the resource embedded" do+ expect(subject)+ .to be_json_eql(embedded_resource_type.to_json)+ .at_path("#{embedded_path}/_type")++ expect(subject)+ .to be_json_eql(embedded_resource.name.to_json)+ .at_path("#{embedded_path}/name")+ end+ end++ context "when resources are not embedded" do+ let(:embed_links) { false }++ it "has the resource not embedded" do+ expect(subject)+ .not_to have_json_path("#{embedded_path}/_type")+ end+ end+end++RSpec.shared_examples_for "has the resource not embedded" do+ let(:embedded_path) do+ super()+ rescue NoMethodError+ raise "'embedded_path' not defined in a let block"+ end++ it "has the resource not embedded" do+ expect(subject)+ .not_to have_json_path(embedded_path.to_s)+ end+enddiff --git a/spec/lib/api/v3/utilities/path_helper_spec.rb b/spec/lib/api/v3/utilities/path_helper_spec.rbindex 109cb298a06..70a9772011a 100644--- a/spec/lib/api/v3/utilities/path_helper_spec.rb+++ b/spec/lib/api/v3/utilities/path_helper_spec.rb@@ -296,6 +296,10 @@ RSpec.describe API::V3::Utilities::PathHelper doendend+ describe "project phase definition paths" do+ it_behaves_like "show", :project_phase_definition+ end+describe "project status paths" doit_behaves_like "show", :project_statusenddiff --git a/spec/lib/api/v3/work_packages/schema/work_package_schema_representer_spec.rb b/spec/lib/api/v3/work_packages/schema/work_package_schema_representer_spec.rbindex f7c61346989..f30b89f7531 100644--- a/spec/lib/api/v3/work_packages/schema/work_package_schema_representer_spec.rb+++ b/spec/lib/api/v3/work_packages/schema/work_package_schema_representer_spec.rb@@ -1,3 +1,5 @@+# frozen_string_literal: true+#-- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH@@ -823,6 +825,41 @@ RSpec.describe API::V3::WorkPackages::Schema::WorkPackageSchemaRepresenter doendend+ describe "projectPhaseDefinition" do+ # TODO: spec feature flag+ context "with the view_project_phases permission" do+ let(:permissions) { %i[edit_work_packages view_project_phases] }++ it_behaves_like "has basic schema properties" do+ let(:path) { "projectPhaseDefinition" }+ let(:type) { "ProjectPhaseDefinition" }+ let(:name) { I18n.t("attributes.project_phase") }+ let(:required) { false }+ let(:writable) { false }+ let(:location) { "_links" }+ end+ end++ context "with the edit_project_phases permission" do+ let(:permissions) { %i[edit_work_packages view_project_phases edit_project_phases] }++ it_behaves_like "has basic schema properties" do+ let(:path) { "projectPhaseDefinition" }+ let(:type) { "ProjectPhaseDefinition" }+ let(:name) { I18n.t("attributes.project_phase") }+ let(:required) { false }+ let(:writable) { true }+ let(:location) { "_links" }+ end+ end++ context "without the view_project_phases permission view time_entries permission" do+ it "has no spentTime attribute" do+ expect(subject).not_to have_json_path("projectPhaseDefinitions")+ end+ end+ end+describe "parent" doit_behaves_like "has basic schema properties" dolet(:path) { "parent" }@@ -1245,7 +1282,7 @@ RSpec.describe API::V3::WorkPackages::Schema::WorkPackageSchemaRepresenter doendend- context "if the type is switches" do+ context "if the locale is switched" doit_behaves_like "changes" dolet(:change) { allow(I18n).to receive(:locale).and_return(:de) }enddiff --git a/spec/lib/api/v3/work_packages/work_package_representer_spec.rb b/spec/lib/api/v3/work_packages/work_package_representer_spec.rbindex af7024edad8..c6188e49b5f 100644--- a/spec/lib/api/v3/work_packages/work_package_representer_spec.rb+++ b/spec/lib/api/v3/work_packages/work_package_representer_spec.rb@@ -1,3 +1,5 @@+# frozen_string_literal: true+#-- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH@@ -65,6 +67,7 @@ RSpec.describe API::V3::WorkPackages::WorkPackageRepresenter doparent:,type:,project:,+ project_phase_definition:,priority:,assigned_to: assignee,responsible:,@@ -94,10 +97,13 @@ RSpec.describe API::V3::WorkPackages::WorkPackageRepresenter doview_file_linksmanage_file_linksdelete_work_packages+ view_project_phases]endlet(:permissions) { all_permissions }- let(:project) { build_stubbed(:project_with_types) }+ let(:project) { build_stubbed(:project_with_types, phases: project_phase.present? ? [project_phase] : []) }+ let(:project_phase) { build_stubbed(:project_phase, definition: project_phase_definition) }+ let(:project_phase_definition) { build_stubbed(:project_phase_definition) }let(:type) dotype = project.types.first@@ -668,6 +674,50 @@ RSpec.describe API::V3::WorkPackages::WorkPackageRepresenter doendend+ describe "projectPhaseDefinition" do+ context "without a phase being set" do+ before do+ work_package.project_phase_definition = nil+ end++ it_behaves_like "has an empty link" do+ let(:link) { "projectPhaseDefinition" }+ end+ end++ context "with a phase being set" do+ it_behaves_like "has a titled link" do+ let(:link) { "projectPhaseDefinition" }+ let(:href) { api_v3_paths.project_phase_definition(project_phase_definition.id) }+ let(:title) { project_phase_definition.name }+ end+ end++ context "with the phase not existing in the project" do+ let(:project_phase) { nil }++ it_behaves_like "has an empty link" do+ let(:link) { "projectPhaseDefinition" }+ end+ end++ context "with the phase being inactive in the project" do+ let(:project_phase) { build_stubbed(:project_phase, active: false, definition: project_phase_definition) }++ it_behaves_like "has an empty link" do+ let(:link) { "projectPhaseDefinition" }+ end+ end++ context "without the user being allowed to see the reference" do+ let(:permissions) { all_permissions - [:view_project_phases] }++ it_behaves_like "has no link" do+ let(:link) { "projectPhaseDefinition" }+ end+ end+ end+describe "category" dolet(:embedded_path) { "_embedded/category" }let(:href_path) { "_links/category/href" }@@ -1312,6 +1362,42 @@ RSpec.describe API::V3::WorkPackages::WorkPackageRepresenter doendend+ describe "projectPhaseDefinition" do+ let(:embedded_path) { "_embedded/projectPhaseDefinition" }+ let(:embedded_resource) { project_phase_definition }+ let(:embedded_resource_type) { "ProjectPhaseDefinition" }++ context "without a phase being set" do+ before do+ work_package.project_phase_definition = nil+ end++ it_behaves_like "has the resource not embedded"+ end++ context "with a phase being set" do+ it_behaves_like "has the resource embedded"+ end++ context "with the phase not existing in the project" do+ let(:project_phase) { nil }++ it_behaves_like "has the resource not embedded"+ end++ context "with the phase being inactive in the project" do+ let(:project_phase) { build_stubbed(:project_phase, active: false, definition: project_phase_definition) }++ it_behaves_like "has the resource not embedded"+ end++ context "without the user being allowed to see the reference" do+ let(:permissions) { all_permissions - [:view_project_phases] }++ it_behaves_like "has the resource not embedded"+ end+ end+context "when passing timestamps" dolet(:timestamps) { [Timestamp.new(baseline_time), Timestamp.now] }let(:baseline_time) { Time.zone.parse("2022-01-01") }@@ -1448,6 +1534,7 @@ RSpec.describe API::V3::WorkPackages::WorkPackageRepresenter doenddescribe "caching" do+ # TODO: include project_phase and phase_definition into the cache keyit "is based on the representer's cache_key" doallow(OpenProject::Cache).to receive(:fetch)diff --git a/spec/models/work_package_spec.rb b/spec/models/work_package_spec.rbindex fa70aba8adc..0c67309347d 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_phase).class_name("Project::Phase").optional }+ it { is_expected.to belong_to(:project_phase_definition).class_name("Project::PhaseDefinition").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) }