mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-23 23:58:31 -05:00
Merge pull request #3912 from tgxworld/fix_category_logging
FIX: Admin logging should not log permissions if none has been set.
This commit is contained in:
commit
4ed93eee06
2 changed files with 12 additions and 1 deletions
|
@ -215,7 +215,7 @@ class StaffActionLogger
|
|||
|
||||
changed_attributes = category.previous_changes.slice(*category_params.keys)
|
||||
|
||||
if old_permissions != category_params[:permissions]
|
||||
if !old_permissions.empty? && (old_permissions != category_params[:permissions])
|
||||
changed_attributes.merge!({ permissions: [old_permissions.to_json, category_params[:permissions].to_json] })
|
||||
end
|
||||
|
||||
|
|
|
@ -306,6 +306,17 @@ describe StaffActionLogger do
|
|||
expect(name_user_history.previous_value).to eq('haha')
|
||||
expect(name_user_history.new_value).to eq('new_name')
|
||||
end
|
||||
|
||||
it "does not log permissions changes for category visible to everyone" do
|
||||
attributes = { name: 'new_name' }
|
||||
old_permission = category.permissions_params
|
||||
category.update!(attributes)
|
||||
|
||||
logger.log_category_settings_change(category, attributes.merge({ permissions: { "everyone" => 1 } }), old_permission)
|
||||
|
||||
expect(UserHistory.count).to eq(1)
|
||||
expect(UserHistory.find_by_subject('name').category).to eq(category)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'log_category_deletion' do
|
||||
|
|
Loading…
Reference in a new issue