diff --git a/app/controllers/dois_controller.rb b/app/controllers/dois_controller.rb index 5c518cbb2..3c7356396 100644 --- a/app/controllers/dois_controller.rb +++ b/app/controllers/dois_controller.rb @@ -569,9 +569,8 @@ def safe_params # merge attributes from xml into regular attributes # make sure we don't accidentally set any attributes to nil - # set container even if empty, as the content is read-only and generated from other properties read_attrs_keys.each do |attr| - p.merge!(attr.to_s.underscore => p[attr].presence || meta[attr.to_s.underscore]) if p.has_key?(attr) || meta[attr.to_s.underscore].present? || attr == :container + p.merge!(attr.to_s.underscore => p[attr].presence || meta[attr.to_s.underscore].presence || p[attr]) if p.has_key?(attr) || meta.has_key?(attr.to_s.underscore) end p.merge!(version_info: p[:version] || meta["version_info"]) if p.has_key?(:version_info) || meta["version_info"].present? diff --git a/spec/requests/dois_spec.rb b/spec/requests/dois_spec.rb index 603c66ea3..a1f27eafd 100644 --- a/spec/requests/dois_spec.rb +++ b/spec/requests/dois_spec.rb @@ -2129,7 +2129,7 @@ patch "/dois/#{doi.doi}", params: update_attributes_again.to_json, headers: headers expect(json.dig('data', 'attributes', 'descriptions').size).to eq(1) - expect(json.dig('data', 'attributes', 'container')).to be_empty + expect(json.dig('data', 'attributes', 'container')).to be_nil end end