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

baseline api: removing redundant `baselineAttributes`

Sebastian Fiedlschuster22c95c45c82f
diff --git a/lib/api/v3/work_packages/work_package_representer.rb b/lib/api/v3/work_packages/work_package_representer.rb
index aed22ed8c05..49dfe27e2ea 100644
--- a/lib/api/v3/work_packages/work_package_representer.rb
+++ b/lib/api/v3/work_packages/work_package_representer.rb
@@ -478,33 +478,6 @@ module API
status_id && status.is_readonly?
end
- property :baseline_attributes,
- as: :baselineAttributes,
- if: ->(*) { respond_to?(:baseline_attributes) and baseline_timestamp.present? },
- getter: ->(*) do
- attrs = baseline_attributes.to_h
- if exists_at_timestamps.include?(baseline_timestamp)
- attrs = attrs.merge({
- '_links': {
- 'self': {
- 'href': API::V3::Utilities::PathHelper::ApiV3Path \
- .work_package(id, timestamps: baseline_timestamp)
- }
- }
- })
- end
- attrs = attrs.merge({
- '_meta': {
- 'timestamp': baseline_timestamp.to_s,
- 'matchesFilters': matches_query_filters_at_baseline_timestamp?,
- 'exists': exists_at_timestamps.include?(baseline_timestamp)
- }.compact
- })
- attrs
- end,
- embedded: true,
- uncacheable: true
-
property :attributes_by_timestamp,
as: :attributesByTimestamp,
if: ->(*) { respond_to?(:attributes_by_timestamp) and respond_to?(:timestamps) and timestamps != [Timestamp.now] },
diff --git a/spec/lib/api/v3/work_packages/work_package_collection_representer_spec.rb b/spec/lib/api/v3/work_packages/work_package_collection_representer_spec.rb
index aeba5f25099..f6179f4a3de 100644
--- a/spec/lib/api/v3/work_packages/work_package_collection_representer_spec.rb
+++ b/spec/lib/api/v3/work_packages/work_package_collection_representer_spec.rb
@@ -560,18 +560,6 @@ describe API::V3::WorkPackages::WorkPackageCollectionRepresenter do
.to be_json_eql(api_v3_paths.work_package(work_package.id, timestamps: timestamps.first).to_json)
.at_path("_embedded/elements/0/_embedded/attributesByTimestamp/0/_links/self/href")
end
-
- it 'embeds the properties of the baseline work package in baselineAttributes' do
- expect(collection)
- .to be_json_eql("The original work package".to_json)
- .at_path("_embedded/elements/0/_embedded/baselineAttributes/subject")
- end
-
- it 'embeds the link to the baseline work package in baselineAttributes' do
- expect(collection)
- .to be_json_eql(api_v3_paths.work_package(work_package.id, timestamps: timestamps.first).to_json)
- .at_path("_embedded/elements/0/_embedded/baselineAttributes/_links/self/href")
- end
end
shared_examples_for 'has the absolute timestamps within the self link' do
@@ -650,14 +638,6 @@ describe API::V3::WorkPackages::WorkPackageCollectionRepresenter do
context 'with baseline and current timestamps' do
let(:timestamps) { [Timestamp.parse("2022-01-01T00:00:00Z"), Timestamp.parse("PT0S")] }
- describe 'baselineAttributes' do
- it 'states whether the work package matches the query filters at the baseline time' do
- expect(subject)
- .to be_json_eql(true.to_json)
- .at_path('_embedded/elements/0/_embedded/baselineAttributes/_meta/matchesFilters')
- end
- end
-
describe 'attributesByTimestamp' do
it 'states whether the work package matches the query filters at the timestamp' do
expect(subject)
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 f047717b032..71737fc7b15 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
@@ -1348,32 +1348,6 @@ describe API::V3::WorkPackages::WorkPackageRepresenter do
current_journal
end
- describe 'baselineAttributes' do
- it 'has the work package attributes at the baseline time' do
- expect(subject)
- .to be_json_eql('The original work package'.to_json)
- .at_path('_embedded/baselineAttributes/subject')
- end
-
- it 'has a link to the baseline work package' do
- expect(subject)
- .to be_json_eql(api_v3_paths.work_package(work_package.id, timestamps: [timestamps.first]).to_json)
- .at_path('_embedded/baselineAttributes/_links/self/href')
- end
-
- it 'has the baseline timestamp as meta information' do
- expect(subject)
- .to be_json_eql(timestamps.first.to_s.to_json)
- .at_path('_embedded/baselineAttributes/_meta/timestamp')
- end
-
- it 'has no information about whether the work package matches the query filters at the baseline time' \
- 'because there are no filters without a query' do
- expect(subject)
- .not_to have_json_path('_embedded/baselineAttributes/_meta/matchesFilters')
- end
- end
-
describe 'attributesByTimestamp' do
it 'has an array' do
expect(JSON.parse(subject)['_embedded']['attributesByTimestamp']).to be_an Array
@@ -1437,14 +1411,6 @@ describe API::V3::WorkPackages::WorkPackageRepresenter do
member_with_permissions: %i[view_work_packages view_file_links])
end
- describe 'baselineAttributes' do
- it 'states whether the work package matches the query filters at the baseline time' do
- expect(subject)
- .to be_json_eql(true.to_json)
- .at_path('_embedded/baselineAttributes/_meta/matchesFilters')
- end
- end
-
describe 'attributesByTimestamp' do
it 'states whether the work package matches the query filters at the timestamp' do
expect(subject)
diff --git a/spec/requests/api/v3/work_packages/index_resource_spec.rb b/spec/requests/api/v3/work_packages/index_resource_spec.rb
index 684baf22a30..bb317248d51 100644
--- a/spec/requests/api/v3/work_packages/index_resource_spec.rb
+++ b/spec/requests/api/v3/work_packages/index_resource_spec.rb
@@ -282,17 +282,6 @@ describe 'API v3 Work package resource',
expect(subject.status).to be 200
end
- it 'embeds the baselineAttributes' do
- expect(subject.body)
- .to be_json_eql("The original work package".to_json)
- .at_path('_embedded/elements/0/_embedded/baselineAttributes/subject')
- end
-
- it 'does not embed the attributes in baselineAttributes if they are the same as the current attributes' do
- expect(subject.body)
- .not_to have_json_path('_embedded/elements/0/_embedded/baselineAttributes/description')
- end
-
it 'embeds the attributesByTimestamp' do
expect(subject.body)
.to be_json_eql("The original work package".to_json)
@@ -477,18 +466,6 @@ describe 'API v3 Work package resource',
end
end
end
-
- describe "baselineAttributes" do
- describe "_meta" do
- describe "matchesFilters" do
- it 'marks the work package as matching the filters at the baseline time' do
- expect(subject.body)
- .to be_json_eql(true.to_json)
- .at_path('_embedded/elements/0/_embedded/baselineAttributes/_meta/matchesFilters')
- end
- end
- end
- end
end
end
@@ -496,33 +473,6 @@ describe 'API v3 Work package resource',
let(:timestamps) { [Timestamp.parse('2015-01-01T00:00:00Z'), Timestamp.now] }
let(:created_at) { 10.days.ago }
- describe "baselineAttributes" do
- describe "_meta" do
- describe "exists" do
- it 'marks the work package as not existing at the baseline time' do
- expect(subject.body)
- .to be_json_eql(false.to_json)
- .at_path('_embedded/elements/0/_embedded/baselineAttributes/_meta/exists')
- end
- end
-
- describe "matchesFilters" do
- it 'marks the work package as not matching the filters at the baseline time' do
- expect(subject.body)
- .to be_json_eql(false.to_json)
- .at_path('_embedded/elements/0/_embedded/baselineAttributes/_meta/matchesFilters')
- end
- end
- end
-
- describe "_links" do
- it 'is not present' do
- expect(subject.body)
- .not_to have_json_path('_embedded/elements/0/_embedded/baselineAttributes/_links')
- end
- end
- end
-
describe "attributesByTimestamp" do
describe "0 (baseline attributes)" do
it 'has no attributes because the work package did not exist at the baseline time' do
diff --git a/spec/requests/api/v3/work_packages/show_resource_spec.rb b/spec/requests/api/v3/work_packages/show_resource_spec.rb
index 2f6b670442e..f3058f4c86e 100644
--- a/spec/requests/api/v3/work_packages/show_resource_spec.rb
+++ b/spec/requests/api/v3/work_packages/show_resource_spec.rb
@@ -259,17 +259,6 @@ describe 'API v3 Work package resource',
expect(subject && last_response.status).to eq(200)
end
- it 'embeds the baselineAttributes' do
- expect(subject)
- .to be_json_eql("The original work package".to_json)
- .at_path('_embedded/baselineAttributes/subject')
- end
-
- it 'does not embed the attributes in baselineAttributes if they are the same as the current attributes' do
- expect(subject)
- .not_to have_json_path('_embedded/baselineAttributes/description')
- end
-
it 'embeds the attributesByTimestamp' do
expect(subject)
.to be_json_eql("The original work package".to_json)