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 texts for resource creation
Klaus Zandersda189c6249a7
diff --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 024b9df2267..df9aad9164c 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@@ -102,7 +102,7 @@ module APIassociated_resource :work_package,skip_render: ->(*) { represented.entity_type != "WorkPackage" },getter: ->(*) { represented.entity if represented.entity_type == "WorkPackage" },- setter: ->(value) { represented.entity = value }+ setter: ::API::V3::TimeEntries::EntityRepresenterFactory.create_setter_lambda(:entity)associated_resource :userdiff --git a/modules/costs/spec/requests/api/time_entries/create_resource_spec.rb b/modules/costs/spec/requests/api/time_entries/create_resource_spec.rbindex 8d035ab6bb0..2157c69028e 100644--- a/modules/costs/spec/requests/api/time_entries/create_resource_spec.rb+++ b/modules/costs/spec/requests/api/time_entries/create_resource_spec.rb@@ -65,7 +65,7 @@ RSpec.describe "API v3 Time Entries resource",let(:parameters) do{_links: {- workPackage: { href: api_v3_paths.work_package(work_package.id) },+ entity: { href: api_v3_paths.work_package(work_package.id) },project: { href: api_v3_paths.project(project.id) },activity: { href: api_v3_paths.time_entries_activity(active_activity.id) }},@@ -87,6 +87,37 @@ RSpec.describe "API v3 Time Entries resource",expect(time_entry.start_time).to eq(13 * 60) # 12:00 UTC = 13:00 Berlin on December 24th, 2024expect(time_entry.time_zone).to eq("Europe/Berlin")expect(time_entry.user).to eq(german_user)+ expect(time_entry.entity).to eq(work_package)+ end++ context "with the deprecated workPackge field" do+ let(:parameters) do+ {+ _links: {+ workPackage: { href: api_v3_paths.work_package(work_package.id) },+ project: { href: api_v3_paths.project(project.id) },+ activity: { href: api_v3_paths.time_entries_activity(active_activity.id) }+ },+ spentOn: "2024-12-24",+ hours: "PT2H",+ startTime: "2024-12-24T12:00:00Z"+ }+ end++ it "creates the time entry" do+ post path, parameters.to_json++ expect(subject).to have_http_status(:created)+ time_entry_id = json_response["id"]+ time_entry = TimeEntry.find(time_entry_id)++ expect(time_entry.spent_on).to eq(Date.new(2024, 12, 24))+ expect(time_entry.hours).to eq(2)+ expect(time_entry.start_time).to eq(13 * 60) # 12:00 UTC = 13:00 Berlin on December 24th, 2024+ expect(time_entry.time_zone).to eq("Europe/Berlin")+ expect(time_entry.user).to eq(german_user)+ expect(time_entry.entity).to eq(work_package)+ endendend@@ -95,7 +126,7 @@ RSpec.describe "API v3 Time Entries resource",{_links: {user: { href: api_v3_paths.user(japanese_user.id) },- workPackage: { href: api_v3_paths.work_package(work_package.id) },+ entity: { href: api_v3_paths.work_package(work_package.id) },project: { href: api_v3_paths.project(project.id) },activity: { href: api_v3_paths.time_entries_activity(active_activity.id) }},@@ -117,6 +148,7 @@ RSpec.describe "API v3 Time Entries resource",expect(time_entry.start_time).to eq(21 * 60) # 12:00 UTC = 21:00 Tokyo on Dec 24th, 2024expect(time_entry.time_zone).to eq("Asia/Tokyo")expect(time_entry.user).to eq(japanese_user)+ expect(time_entry.entity).to eq(work_package)endendend