DEV: Allow for setting a message with SiteSetting.set_and_log (#27447)

When we turn on settings automatically for customers,
we sometimes use `.set_and_log` which will make a staff
action log for the site setting change. This is fine, but
there is no context for customers.

This change allows setting a message with `.set_and_log`, which
will be stored in the `details` column of the staff action log
created, which will show up on `/admin/logs/staff_action_logs`

---------

Co-authored-by: Kelv <kelv@discourse.org>
This commit is contained in:
Martin Brennan
2024-06-13 14:59:49 +10:00
committed by GitHub
parent dee71f5918
commit e94ab11477
6 changed files with 126 additions and 4 deletions

View File

@ -569,6 +569,16 @@ RSpec.describe SiteSettingExtension do
expect(UserHistory.last.previous_value).to eq("Discourse v1")
expect(UserHistory.last.new_value).to eq("Discourse v2")
end
context "when a detailed message is provided" do
let(:message) { "We really need to do this, see https://meta.discourse.org/t/123" }
it "adds the detailed message to the user history record" do
expect {
settings.set_and_log("title", "Discourse v2", Discourse.system_user, message)
}.to change { UserHistory.last.try(:details) }.to(message)
end
end
end
describe "filter domain name" do