FIX: Update only passed custom fields (#14357)

It used to replace custom fields instead of updating only the custom
fields that were passed. The changes to custom fields will also be
logged.
This commit is contained in:
Bianca Nenciu
2021-09-17 13:37:56 +03:00
committed by GitHub
parent 8002b95682
commit c9ad9bff8a
4 changed files with 42 additions and 8 deletions

View File

@@ -352,8 +352,10 @@ describe StaffActionLogger do
category.update!(attributes)
logger.log_category_settings_change(category, attributes,
category_group.group_name => category_group.permission_type
logger.log_category_settings_change(
category,
attributes,
old_permissions: { category_group.group_name => category_group.permission_type }
)
expect(UserHistory.count).to eq(2)
@@ -376,7 +378,11 @@ describe StaffActionLogger do
old_permission = category.permissions_params
category.update!(attributes)
logger.log_category_settings_change(category, attributes.merge(permissions: { "everyone" => 1 }), old_permission)
logger.log_category_settings_change(
category,
attributes.merge(permissions: { "everyone" => 1 }),
old_permissions: old_permission
)
expect(UserHistory.count).to eq(1)
expect(UserHistory.find_by_subject('name').category).to eq(category)