FIX: do not log category custom fields changes if the value is unchanged (#16712)

This commit is contained in:
Arpit Jalan
2022-05-11 13:51:51 +05:30
committed by GitHub
parent 631bfb2a23
commit 977da1da77
2 changed files with 33 additions and 0 deletions
+32
View File
@@ -387,6 +387,38 @@ describe StaffActionLogger do
expect(UserHistory.count).to eq(1)
expect(UserHistory.find_by_subject('name').category).to eq(category)
end
it "logs custom fields changes" do
attributes = {
custom_fields: { "auto_populated" => "t" }
}
category.update!(attributes)
logger.log_category_settings_change(
category,
attributes,
old_permissions: category.permissions_params,
old_custom_fields: {}
)
expect(UserHistory.count).to eq(1)
end
it "does not log custom fields changes if value is unchanged" do
attributes = {
custom_fields: { "auto_populated" => "t" }
}
category.update!(attributes)
logger.log_category_settings_change(
category,
attributes,
old_permissions: category.permissions_params,
old_custom_fields: { "auto_populated" => "t" }
)
expect(UserHistory.count).to eq(0)
end
end
describe 'log_category_deletion' do