Skip to content

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

[#48248] Work package in query without timestamps have cached timestamps url parameter

Dombi Attilac86cf5be01bd
diff --git a/lib/api/decorators/self_link.rb b/lib/api/decorators/self_link.rb
index 9a4166798a2..f1e4d142f56 100644
--- a/lib/api/decorators/self_link.rb
+++ b/lib/api/decorators/self_link.rb
@@ -55,8 +55,12 @@ module API
def self_link(path: nil,
id_attribute: :id,
title: true,
- title_getter: ->(*) { represented.name })
- link :self do
+ title_getter: ->(*) { represented.name },
+ **options)
+
+ self_config = { rel: :self }.merge(options)
+
+ link self_config do
self_path = self_v3_path(path, id_attribute)
link_object = { href: self_path }
diff --git a/lib/api/v3/work_packages/work_package_representer.rb b/lib/api/v3/work_packages/work_package_representer.rb
index 5b304a3a109..52b179b6d41 100644
--- a/lib/api/v3/work_packages/work_package_representer.rb
+++ b/lib/api/v3/work_packages/work_package_representer.rb
@@ -60,7 +60,8 @@ module API
api_v3_paths.work_package(represented.id, timestamps:)
end
- self_link title_getter: ->(*) { represented.subject }
+ self_link title_getter: ->(*) { represented.subject },
+ uncacheable: true
link :update,
cache_if: -> { current_user_update_allowed? } do
diff --git a/spec/lib/api/v3/work_packages/work_package_representer_spec.rb b/spec/lib/api/v3/work_packages/work_package_representer_spec.rb
index 38630ae8f6d..990bdfcde0f 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
@@ -1429,6 +1429,27 @@ describe API::V3::WorkPackages::WorkPackageRepresenter do
end
end
+ describe '_links' do
+ it_behaves_like 'has a titled link' do
+ let(:link) { 'self' }
+ let(:href) { api_v3_paths.work_package(work_package.id, timestamps:) }
+ let(:title) { work_package.name }
+ end
+
+ context 'when changing timestamps it updates the link' do
+ it_behaves_like 'has a titled link' do
+ before do
+ representer.to_json
+ representer.timestamps = []
+ end
+
+ let(:link) { 'self' }
+ let(:href) { api_v3_paths.work_package(work_package.id) }
+ let(:title) { work_package.name }
+ end
+ end
+ end
+
describe '_meta' do
describe 'matchesFilters' do
it 'states whether the work package matches the query filters at the last timestamp' do