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
Add specs for attributesByTimestamp _links custom field
Dombi Attila546efd5bb9e9
diff --git a/lib/api/v3/work_packages/work_package_at_timestamp_representer.rb b/lib/api/v3/work_packages/work_package_at_timestamp_representer.rbindex fdd48083ada..7b342c63f7f 100644--- a/lib/api/v3/work_packages/work_package_at_timestamp_representer.rb+++ b/lib/api/v3/work_packages/work_package_at_timestamp_representer.rb@@ -54,7 +54,7 @@ module APIparent].freeze- SUPPORTED_CUSTOM_PROPERTIES = [/^custom_field_\d+$/].freeze+ SUPPORTED_CUSTOM_PROPERTIES = [/^customField\d+$/].freezeSUPPORTED_PROPERTIES = (SUPPORTED_NON_LINK_PROPERTIES + SUPPORTED_LINK_PROPERTIES).freeze@@ -102,7 +102,7 @@ module APIrepresented.attributes_changed_to_baseline.flat_map do |property|- if property.ends_with?('_id')+ if property.ends_with?('_id') || property.starts_with?("custom_field_")API::Utilities::PropertyNameConverter.from_ar_name(property)elsif %w[start_date due_date].include?(property)['date', property]diff --git a/spec/requests/api/v3/work_packages/index_resource_spec.rb b/spec/requests/api/v3/work_packages/index_resource_spec.rbindex e1c821401c5..040479cc2bb 100644--- a/spec/requests/api/v3/work_packages/index_resource_spec.rb+++ b/spec/requests/api/v3/work_packages/index_resource_spec.rb@@ -386,6 +386,48 @@ RSpec.describe 'API v3 Work package resource',endend+ context 'when a link type custom value changes' do+ let(:original_user) { create(:user, member_in_project: project, member_through_role: role) }+ let(:custom_field) do+ create(:user_wp_custom_field,+ name: 'User CF',+ types: project.types,+ projects: [project])+ end++ let(:custom_value) do+ create(:custom_value,+ custom_field:,+ customized: work_package,+ value: current_user.id)+ end++ before do+ custom_value+ create_customizable_journal(journal: original_journal, custom_field:, value: original_user.id)+ create_customizable_journal(journal: current_journal, custom_field:, value: custom_value.value)+ end++ it 'embeds the custom fields in the attributesByTimestamp' do+ expect(subject.body)+ .to be_json_eql(original_user.name.to_json)+ .at_path("_embedded/elements/0/_embedded/attributesByTimestamp/0/_links/customField#{custom_field.id}/title")+ expect(subject.body)+ .to be_json_eql(current_user.name.to_json)+ .at_path("_embedded/elements/0/_links/customField#{custom_field.id}/title")+ expect(subject.body)+ .to have_json_path("_embedded/elements/0/_embedded/attributesByTimestamp/1")+ expect(subject.body)+ .not_to have_json_path("_embedded/elements/0/_embedded/attributesByTimestamp/1/_links/customField#{custom_field.id}")+ end++ it 'includes a custom field description in the schema' do+ expect(subject.body)+ .to be_json_eql(custom_field.name.to_json)+ .at_path("_embedded/schemas/_embedded/elements/0/customField#{custom_field.id}/name")+ end+ end+context 'when there is a custom value in the past but not in the now as the custom field has been destroyed' dobefore docreate_customizable_journal(journal: original_journal, custom_field:, value: 'Original value')