From 966d749e452c638be33c628dbcc7ae987885f455 Mon Sep 17 00:00:00 2001 From: Jens Ulferts Date: Thu, 10 Dec 2015 11:12:30 +0100 Subject: [PATCH] add parentId field to schema This is somewhat debateable. Having a parentId field is wrong in itself. It should be a linked resource. But as the field is also present in the resource, it also needs to be part of the schema for consistency sake. --- .../schema/work_package_schema_representer.rb | 5 +++++ .../schema/work_package_schema_representer_spec.rb | 10 ++++++++++ 2 files changed, 15 insertions(+) diff --git a/lib/api/v3/work_packages/schema/work_package_schema_representer.rb b/lib/api/v3/work_packages/schema/work_package_schema_representer.rb index 3ed868385a..986c5a5a60 100644 --- a/lib/api/v3/work_packages/schema/work_package_schema_representer.rb +++ b/lib/api/v3/work_packages/schema/work_package_schema_representer.rb @@ -114,6 +114,11 @@ module API schema :project, type: 'Project' + schema :parent_id, + type: 'Integer', + required: false, + writable: true + schema_with_allowed_link :assignee, type: 'User', required: false, diff --git a/spec/lib/api/v3/work_packages/schema/work_package_schema_representer_spec.rb b/spec/lib/api/v3/work_packages/schema/work_package_schema_representer_spec.rb index 040abbaa63..3198c71f4e 100644 --- a/spec/lib/api/v3/work_packages/schema/work_package_schema_representer_spec.rb +++ b/spec/lib/api/v3/work_packages/schema/work_package_schema_representer_spec.rb @@ -370,6 +370,16 @@ describe ::API::V3::WorkPackages::Schema::WorkPackageSchemaRepresenter do end end + describe 'parentId' do + it_behaves_like 'has basic schema properties' do + let(:path) { 'parentId' } + let(:type) { 'Integer' } + let(:name) { I18n.t('activerecord.attributes.work_package.parent') } + let(:required) { false } + let(:writable) { true } + end + end + describe 'type' do it_behaves_like 'has basic schema properties' do let(:path) { 'type' }