add readonly property to wp schema

pull/10801/head
ulferts 2 years ago
parent 15136f417c
commit 9b727f2eec
No known key found for this signature in database
GPG Key ID: A205708DE1284017
  1. 1
      config/locales/en.yml
  2. 6
      lib/api/v3/work_packages/schema/work_package_schema_representer.rb
  3. 19
      spec/lib/api/v3/work_packages/schema/work_package_schema_representer_spec.rb

@ -587,6 +587,7 @@ en:
parent_work_package: "Parent"
priority: "Priority"
progress: "Progress (%)"
readonly: "Read only"
schedule_manually: "Manual scheduling"
spent_hours: "Spent time"
spent_time: "Spent time"

@ -176,6 +176,12 @@ module API
show_if: ->(*) { Setting.work_package_done_ratio != 'disabled' },
required: false
schema :readonly,
type: 'Boolean',
show_if: ->(*) { Status.can_readonly? },
required: false,
has_default: true
schema :created_at,
type: 'DateTime'

@ -661,6 +661,25 @@ describe ::API::V3::WorkPackages::Schema::WorkPackageSchemaRepresenter do
end
end
describe 'readonly' do
context 'with the enterprise feature enabled', with_ee: %i[readonly_work_packages] do
it_behaves_like 'has basic schema properties' do
let(:path) { 'readonly' }
let(:type) { 'Boolean' }
let(:name) { I18n.t('activerecord.attributes.work_package.readonly') }
let(:required) { false }
let(:has_default) { true }
let(:writable) { false }
end
end
context 'without the enterprise feature' do
it 'has no such property' do
expect(subject).not_to have_json_path('readonly')
end
end
end
describe 'createdAt' do
it_behaves_like 'has basic schema properties' do
let(:path) { 'createdAt' }

Loading…
Cancel
Save