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
[37510] Fix accesing nil fragment in custom field injector (#9335)
Oliver Günther8ace16047029
diff --git a/lib/api/v3/utilities/custom_field_injector.rb b/lib/api/v3/utilities/custom_field_injector.rbindex fd7635975de..569fee77232 100644--- a/lib/api/v3/utilities/custom_field_injector.rb+++ b/lib/api/v3/utilities/custom_field_injector.rb@@ -272,7 +272,7 @@ module APIdef property_value_setter_for(custom_field)->(fragment:, **) {- value = if custom_field.field_format == 'text'+ value = if fragment && custom_field.field_format == 'text'fragment['raw']elsefragmentdiff --git a/spec/requests/api/v3/work_packages/form/work_package_form_resource_spec.rb b/spec/requests/api/v3/work_packages/form/work_package_form_resource_spec.rbindex 899dc2e69d3..2f6701b6051 100644--- a/spec/requests/api/v3/work_packages/form/work_package_form_resource_spec.rb+++ b/spec/requests/api/v3/work_packages/form/work_package_form_resource_spec.rb@@ -737,6 +737,29 @@ describe 'API v3 Work package form resource', type: :request, with_mail: false dexpect(subject.body).to have_json_path('_embedded/validationErrors/responsible')}end++ describe 'formattable custom field set to nil' do+ let(:custom_field) do+ FactoryBot.create :work_package_custom_field, field_format: 'text'+ end++ let(:cf_param) { { "customField#{custom_field.id}" => nil } }+ let(:params) { valid_params.merge(cf_param) }++ before do+ project.work_package_custom_fields << custom_field+ project.save!+ work_package.type.custom_fields << custom_field+ work_package.save!++ login_as(current_user)+ post post_path, (params ? params.to_json : nil), 'CONTENT_TYPE' => 'application/json'+ end++ it 'should respond with a valid body (Regression OP#37510)' do+ expect(last_response.status).to eq(200)+ end+ endendendend