remove almost duplicate, but faulty, readonly check

The writability of the status is already checked at the attribute level
pull/8437/head
ulferts 4 years ago committed by Oliver Günther
parent cd85434ea6
commit a2a559e553
No known key found for this signature in database
GPG Key ID: A3A8BDAD7C0C552C
  1. 2
      app/contracts/work_packages/base_contract.rb
  2. 3
      lib/api/v3/work_packages/schema/base_work_package_schema.rb
  3. 8
      spec/lib/api/v3/work_packages/schema/specific_work_package_schema_spec.rb

@ -136,7 +136,7 @@ module WorkPackages
ret = super ret = super
# If we're in a readonly status and did not move into that status right now # If we're in a readonly status and did not move into that status right now
# only allow other status transitions # only allow other status transitions. But also prevent that if the associated version is closed.
if model.readonly_status? && !model.status_id_change if model.readonly_status? && !model.status_id_change
ret &= %w(status status_id) ret &= %w(status status_id)
end end

@ -55,9 +55,6 @@ module API
def writable?(property) def writable?(property)
property = property.to_sym property = property.to_sym
# Special case for readonly: Only status is allowed
return property == :status if readonly?
# Special case for milestones + date property # Special case for milestones + date property
property = :start_date if property == :date && milestone? property = :start_date if property == :date && milestone?

@ -92,9 +92,11 @@ describe ::API::V3::WorkPackages::Schema::SpecificWorkPackageSchema do
.to receive(:readonly_status?) .to receive(:readonly_status?)
.and_return(false) .and_return(false)
is_expected.to_not be_readonly # As the writability is memoized we need to have a new schema
expect(subject.writable?(:status)).to be_truthy new_schema = described_class.new(work_package: work_package)
expect(subject.writable?(:subject)).to be_truthy expect(new_schema).to_not be_readonly
expect(new_schema.writable?(:status)).to be_truthy
expect(new_schema.writable?(:subject)).to be_truthy
end end
end end

Loading…
Cancel
Save