mirror of
https://github.com/opf/openproject.git
synced 2026-06-13 19:20:00 +00:00
Simplify test case
This commit is contained in:
@@ -33,7 +33,7 @@ class Type::AttributeGroup < Type::FormGroup
|
||||
# The attributes might not be present anymore, for instance when you remove
|
||||
# a plugin leaving an empty group behind. If we did not delete such a
|
||||
# group, the admin saving such a form configuration would encounter an
|
||||
# unexpected/unexplicable validation error.
|
||||
# unexpected/inexplicable validation error.
|
||||
valid_keys = type.work_package_attributes.keys
|
||||
|
||||
(attributes & valid_keys)
|
||||
|
||||
@@ -106,7 +106,7 @@ module WorkPackageTypes
|
||||
.reject { |group| group.key.to_s == "__empty" }
|
||||
seen_keys = groups.filter_map(&:key).compact_blank.map(&:to_s)
|
||||
groups = groups.map { |group| normalize_group(group, seen_keys:) }
|
||||
groups = prune_unavailable_attribute_group_items(groups)
|
||||
prune_unavailable_attribute_group_items(groups)
|
||||
|
||||
if groups.empty?
|
||||
[::Type::AttributeGroup.new(type, :__empty, [])]
|
||||
|
||||
@@ -71,10 +71,9 @@ module WorkPackageTypes
|
||||
|
||||
it "removes unavailable attributes from legacy form configurations when updating rows" do
|
||||
custom_field = create(:work_package_custom_field, field_format: "string")
|
||||
deleted_custom_field_attribute = "custom_field_999999"
|
||||
removed_plugin_attribute = "removed_plugin_attribute"
|
||||
deleted_custom_field_attribute = "custom_field_1"
|
||||
type.update_column(:attribute_groups, [
|
||||
["Legacy custom group", [deleted_custom_field_attribute, removed_plugin_attribute, "priority"]]
|
||||
["Legacy custom group", [deleted_custom_field_attribute, "priority"]]
|
||||
])
|
||||
|
||||
result = described_class
|
||||
@@ -83,8 +82,9 @@ module WorkPackageTypes
|
||||
|
||||
expect(result).to be_success
|
||||
|
||||
attributes = type.reload.attribute_groups.first.attributes
|
||||
expect(attributes).to eq([custom_field.attribute_name, "priority"])
|
||||
members = type.reload.attribute_groups.first.members
|
||||
expect(members).to include(custom_field.attribute_name, "priority")
|
||||
expect(members).not_to include(deleted_custom_field_attribute)
|
||||
expect(type.custom_field_ids).to contain_exactly(custom_field.id)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user