Merge pull request #8503 from opf/fix/33678/priority-required-field

[33678] Priority needs to be a require field
pull/8505/head
Oliver Günther 4 years ago committed by GitHub
commit 17676c9b29
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      app/models/type/attributes.rb
  2. 2
      lib/api/v3/work_packages/schema/work_package_schema_representer.rb
  3. 4
      spec/lib/api/v3/work_packages/schema/work_package_schema_representer_spec.rb

@ -111,12 +111,20 @@ module Type::Attributes
# * directly in other envs, e.g. test
definitions = representable_config.key?(:definitions) ? representable_config[:definitions] : representable_config
skip = %w[_type _dependencies attribute_groups links parent_id parent description schedule_manually]
definitions.keys
.reject { |key| skip.include?(key) || definitions[key][:required] }
.reject { |key| skipped_attribute?(key, definitions[key]) }
.map { |key| [key, JSON::parse(definitions[key].to_json)] }.to_h
end
def skipped_attribute?(key, definition)
# We always want to include the priority even if its required
return false if key == 'priority'
skip = %w[_type _dependencies attribute_groups links parent_id parent description schedule_manually]
skip.include?(key) || definition[:required]
end
def merge_date_for_form_attributes(attributes)
attributes['date'] = { required: false, has_default: false }
attributes.delete 'due_date'

@ -253,7 +253,7 @@ module API
title: priority.name
}
},
required: false,
required: true,
has_default: true
def attribute_groups

@ -745,7 +745,7 @@ describe ::API::V3::WorkPackages::Schema::WorkPackageSchemaRepresenter do
let(:path) { 'priority' }
let(:type) { 'Priority' }
let(:name) { I18n.t('activerecord.attributes.work_package.priority') }
let(:required) { false }
let(:required) { true }
let(:writable) { true }
let(:has_default) { true }
end
@ -765,7 +765,7 @@ describe ::API::V3::WorkPackages::Schema::WorkPackageSchemaRepresenter do
let(:path) { 'priority' }
let(:type) { 'Priority' }
let(:name) { I18n.t('activerecord.attributes.work_package.priority') }
let(:required) { false }
let(:required) { true }
let(:writable) { false }
let(:has_default) { true }
end

Loading…
Cancel
Save