mirror of
https://github.com/discourse/discourse.git
synced 2025-05-24 03:36:18 +08:00
FIX: Don't error out on empty reserved_usernames setting (#29305)
We're seeing errors in logs due to some sites setting the reserved_usernames setting to nil. This is causing multiple use cases upstream of User#reserved_username? to error out. This commit changes from using the raw #reserved_usernames to using the #reserved_usernames_map helper which exists on list-type site settings. It returns an empty array if the raw value is nil or empty string.
This commit is contained in:
@ -1076,6 +1076,12 @@ RSpec.describe User do
|
||||
expect(User.reserved_username?("löwe")).to eq(true) # NFC
|
||||
expect(User.reserved_username?("käfer")).to eq(true) # NFC
|
||||
end
|
||||
|
||||
it "does not error out when there are no reserved usernames" do
|
||||
SiteSetting.stubs(:reserved_usernames).returns(nil)
|
||||
|
||||
expect { User.username_available?("Foo") }.not_to raise_error
|
||||
end
|
||||
end
|
||||
|
||||
describe "email_validator" do
|
||||
|
Reference in New Issue
Block a user