fix unsetting date on milestone work packages

pull/7403/head
ulferts 5 years ago
parent 53f0b976d0
commit 880120fe1b
No known key found for this signature in database
GPG Key ID: A205708DE1284017
  1. 10
      lib/api/v3/work_packages/work_package_representer.rb
  2. 3
      spec/lib/api/v3/work_packages/work_package_payload_representer_spec.rb

@ -341,12 +341,18 @@ module API
represented.milestone?
}
# Using setter: does not work in case the provided date fragment is nil.
date_property :date,
getter: default_date_getter(:due_date),
setter: ->(fragment:, decorator:, **) {
setter: ->(*) {
# handled in reader
},
reader: ->(decorator:, doc:, **) {
next unless doc.key?('date')
date = decorator
.datetime_formatter
.parse_date(fragment,
.parse_date(doc['date'],
name.to_s.camelize(:lower),
allow_nil: true)

@ -502,6 +502,9 @@ describe ::API::V3::WorkPackages::WorkPackagePayloadRepresenter do
allow(work_package)
.to receive(:milestone?)
.and_return(true)
# Setting values to ensure they are later set to nil in one of the test cases
work_package.start_date = work_package.due_date = Date.today
end
it_behaves_like 'settable ISO 8601 date only' do

Loading…
Cancel
Save