Merge pull request #6395 from opf/fix/27940/dont-sort-attribute-groups

[27940] Don't sort members of attribute groups
pull/6400/head
ulferts 6 years ago committed by GitHub
commit ba123dfd21
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      app/models/type/attribute_group.rb
  2. 25
      spec/models/type/attribute_groups_spec.rb

@ -36,7 +36,7 @@ class Type::AttributeGroup < Type::FormGroup
# unexpected/unexplicable validation error.
valid_keys = type.work_package_attributes.keys
(attributes & valid_keys).sort
(attributes & valid_keys)
end
def ==(other)

@ -221,6 +221,31 @@ describe ::Type, type: :model do
expect(type.save).to be_truthy
expect(type.read_attribute(:attribute_groups)).not_to be_empty
end
context 'with multiple CFs' do
let!(:custom_field2) do
FactoryBot.create(
:work_package_custom_field,
field_format: 'string'
)
end
let(:cf_identifier2) do
:"custom_field_#{custom_field2.id}"
end
it 'they are kept in their respective positions in the group (Regression test #27940)' do
# Enforce fresh lookup of groups
OpenProject::Cache.clear
# Can be enabled
type.attribute_groups = [['foo', [cf_identifier2.to_s, cf_identifier.to_s]]]
expect(type.save).to be_truthy
expect(type.read_attribute(:attribute_groups)).not_to be_empty
cf_group = type.attribute_groups[0]
expect(cf_group.members).to eq([cf_identifier2.to_s, cf_identifier.to_s])
end
end
end
describe 'custom field added implicitly to type' do

Loading…
Cancel
Save