DEV: add site setting to disable watched word checking in user fields (#25411)

adding a hidden sitesetting, `disable_watched_word_checking_in_user_fields` - false by default. if set to true, you can use any word at all in user profile fields.

meta: https://meta.discourse.org/t/watched-words-scope/282699/20
This commit is contained in:
marstall
2024-01-29 12:44:32 -05:00
committed by GitHub
parent 2457553d0a
commit 5a00d1964f
4 changed files with 35 additions and 2 deletions

View File

@ -281,6 +281,11 @@ RSpec.describe User do
context "when user field is private" do
before { user_field.update(show_on_profile: false) }
it { is_expected.to be_valid }
end
context "when SiteSetting.disable_watched_word_checking_in_user_fields is true" do
before { SiteSetting.disable_watched_word_checking_in_user_fields = true }
it { is_expected.to be_valid }
end
end
@ -296,6 +301,15 @@ RSpec.describe User do
user.save!
expect(user_field_value).to eq "■■■■■■■■ word"
end
context "when SiteSetting.disable_watched_word_checking_in_user_fields is true" do
before { SiteSetting.disable_watched_word_checking_in_user_fields = true }
it "does not censor the words upon saving" do
user.save!
expect(user_field_value).to eq "censored word"
end
end
end
context "when user field is private" do
@ -324,6 +338,14 @@ RSpec.describe User do
user.save!
expect(user_field_value).to eq "word replaced"
end
context "when SiteSetting.disable_watched_word_checking_in_user_fields is true" do
before { SiteSetting.disable_watched_word_checking_in_user_fields = true }
it "does not replace anything" do
user.save!
expect(user_field_value).to eq "word to replace"
end
end
end
context "when user field is private" do