mirror of
https://github.com/discourse/discourse.git
synced 2024-11-27 02:23:44 +08:00
FIX: do not log category custom fields changes if the value is unchanged (#16712)
This commit is contained in:
parent
631bfb2a23
commit
977da1da77
|
@ -455,6 +455,7 @@ class StaffActionLogger
|
||||||
|
|
||||||
if old_custom_fields && category_params[:custom_fields]
|
if old_custom_fields && category_params[:custom_fields]
|
||||||
category_params[:custom_fields].each do |key, value|
|
category_params[:custom_fields].each do |key, value|
|
||||||
|
next if old_custom_fields[key] == value
|
||||||
changed_attributes["custom_fields[#{key}]"] = [old_custom_fields[key], value]
|
changed_attributes["custom_fields[#{key}]"] = [old_custom_fields[key], value]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -387,6 +387,38 @@ describe StaffActionLogger do
|
||||||
expect(UserHistory.count).to eq(1)
|
expect(UserHistory.count).to eq(1)
|
||||||
expect(UserHistory.find_by_subject('name').category).to eq(category)
|
expect(UserHistory.find_by_subject('name').category).to eq(category)
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
describe 'log_category_deletion' do
|
describe 'log_category_deletion' do
|
||||||
|
|
Loading…
Reference in New Issue
Block a user