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. 10
      spec/lib/api/v3/work_packages/schema/specific_work_package_schema_spec.rb

@ -136,7 +136,7 @@ module WorkPackages
ret = super
# 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
ret &= %w(status status_id)
end

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

@ -40,7 +40,7 @@ describe ::API::V3::WorkPackages::Schema::SpecificWorkPackageSchema do
double('current user').tap do |u|
allow(u)
.to receive(:allowed_to?)
.and_return(true)
.and_return(true)
end
end
@ -92,9 +92,11 @@ describe ::API::V3::WorkPackages::Schema::SpecificWorkPackageSchema do
.to receive(:readonly_status?)
.and_return(false)
is_expected.to_not be_readonly
expect(subject.writable?(:status)).to be_truthy
expect(subject.writable?(:subject)).to be_truthy
# As the writability is memoized we need to have a new schema
new_schema = described_class.new(work_package: work_package)
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

Loading…
Cancel
Save