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
Fix specs for CostEntry- and TimeEntryRepresenters. Also still include deprecated WP attribute
Klaus Zanders1e89a785c46e
diff --git a/modules/costs/lib/api/v3/cost_entries/cost_entry_representer.rb b/modules/costs/lib/api/v3/cost_entries/cost_entry_representer.rbindex af20c8ffb76..43ed8c2b2f5 100644--- a/modules/costs/lib/api/v3/cost_entries/cost_entry_representer.rb+++ b/modules/costs/lib/api/v3/cost_entries/cost_entry_representer.rb@@ -43,6 +43,10 @@ module APIgetter: ::API::V3::CostEntries::EntityRepresenterFactory.create_getter_lambda(:entity),link: ::API::V3::CostEntries::EntityRepresenterFactory.create_link_lambda(:entity)+ # TODO: DEPRECATED!+ associated_resource :work_package,+ skip_render: ->(*) { represented.entity_type != "WorkPackage" }+property :id, render_nil: trueproperty :units, as: :spentUnitsdiff --git a/modules/costs/lib/api/v3/time_entries/time_entry_representer.rb b/modules/costs/lib/api/v3/time_entries/time_entry_representer.rbindex d95adbd1664..eb02ba53f82 100644--- a/modules/costs/lib/api/v3/time_entries/time_entry_representer.rb+++ b/modules/costs/lib/api/v3/time_entries/time_entry_representer.rb@@ -97,6 +97,10 @@ module APIgetter: ::API::V3::TimeEntries::EntityRepresenterFactory.create_getter_lambda(:entity),link: ::API::V3::TimeEntries::EntityRepresenterFactory.create_link_lambda(:entity)+ # TODO: DEPRECATED!+ associated_resource :work_package,+ skip_render: ->(*) { represented.entity_type != "WorkPackage" }+associated_resource :userdate_time_property :start_time,diff --git a/modules/costs/spec/lib/api/v3/cost_entries/cost_entry_representer_spec.rb b/modules/costs/spec/lib/api/v3/cost_entries/cost_entry_representer_spec.rbindex 1b3d2483708..0993de0907a 100644--- a/modules/costs/spec/lib/api/v3/cost_entries/cost_entry_representer_spec.rb+++ b/modules/costs/spec/lib/api/v3/cost_entries/cost_entry_representer_spec.rb@@ -64,8 +64,8 @@ RSpec.describe API::V3::CostEntries::CostEntryRepresenter doendit_behaves_like "has a titled link" do- let(:link) { "workPackage" }- let(:href) { api_v3_paths.work_package cost_entry.work_package.id }+ let(:link) { "entity" }+ let(:href) { api_v3_paths.work_package cost_entry.entity.id }let(:title) { cost_entry.work_package.subject }enddiff --git a/modules/costs/spec/lib/api/v3/time_entries/time_entry_representer_rendering_spec.rb b/modules/costs/spec/lib/api/v3/time_entries/time_entry_representer_rendering_spec.rbindex 4a27d6f3dfe..a8fd7ab7360 100644--- a/modules/costs/spec/lib/api/v3/time_entries/time_entry_representer_rendering_spec.rb+++ b/modules/costs/spec/lib/api/v3/time_entries/time_entry_representer_rendering_spec.rb@@ -40,11 +40,12 @@ RSpec.describe API::V3::TimeEntries::TimeEntryRepresenter, "rendering" dohours:,activity:,project:,- work_package:,+ entity: work_package,user:)endlet(:project) { build_stubbed(:project) }let(:work_package) { build_stubbed(:work_package, project:) }+ let(:meeting) { build_stubbed(:meeting, project:) }let(:activity) { build_stubbed(:time_entry_activity) }let(:user) { build_stubbed(:user) }let(:current_user) { user }@@ -82,10 +83,34 @@ RSpec.describe API::V3::TimeEntries::TimeEntryRepresenter, "rendering" dolet(:title) { project.name }end- it_behaves_like "has a titled link" do- let(:link) { "workPackage" }- let(:href) { api_v3_paths.work_package work_package.id }- let(:title) { work_package.subject }+ context "with a time entry logged on a work package" do+ it_behaves_like "has a titled link" do+ let(:link) { "entity" }+ let(:href) { api_v3_paths.work_package work_package.id }+ let(:title) { work_package.subject }+ end++ it_behaves_like "has a titled link" do+ let(:link) { "workPackage" }+ let(:href) { api_v3_paths.work_package work_package.id }+ let(:title) { work_package.subject }+ end+ end++ context "with a time entry logged on a meeting" do+ before do+ time_entry.entity = meeting+ end++ it_behaves_like "has a titled link" do+ let(:link) { "entity" }+ let(:href) { api_v3_paths.meeting meeting.id }+ let(:title) { meeting.title }+ end++ it_behaves_like "has no link" do+ let(:link) { "workPackage" }+ endendit_behaves_like "has a titled link" do