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:
Régis Hanol 2015-12-06 10:06:49 +01:00
commit 4ed93eee06
2 changed files with 12 additions and 1 deletions

View File

@ -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

View File

@ -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