FIX: Category permission change not creating a log (#20027)
It didn't create a log if the category was public { "everyone" => 1 }
This commit is contained in:
parent
26b5c0472f
commit
06817bd94f
|
@ -196,6 +196,7 @@ class CategoriesController < ApplicationController
|
|||
category_params[:minimum_required_tags] = 0 if category_params[:minimum_required_tags]&.blank?
|
||||
|
||||
old_permissions = cat.permissions_params
|
||||
old_permissions = { "everyone" => 1 } if old_permissions.empty?
|
||||
|
||||
if result = cat.update(category_params)
|
||||
Scheduler::Defer.later "Log staff action change category settings" do
|
||||
|
|
|
@ -439,18 +439,18 @@ RSpec.describe StaffActionLogger do
|
|||
expect(name_user_history.new_value).to eq("new_name")
|
||||
end
|
||||
|
||||
it "does not log permissions changes for category visible to everyone" do
|
||||
it "logs permissions changes even if the category is visible to everyone" do
|
||||
attributes = { name: "new_name" }
|
||||
old_permission = category.permissions_params
|
||||
old_permission = { "everyone" => 1 }
|
||||
category.update!(attributes)
|
||||
|
||||
logger.log_category_settings_change(
|
||||
category,
|
||||
attributes.merge(permissions: { "everyone" => 1 }),
|
||||
attributes.merge(permissions: { "trust_level_3" => 1 }),
|
||||
old_permissions: old_permission,
|
||||
)
|
||||
|
||||
expect(UserHistory.count).to eq(1)
|
||||
expect(UserHistory.count).to eq(2)
|
||||
expect(UserHistory.find_by_subject("name").category).to eq(category)
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue