2019-04-29 20:27:42 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2022-07-27 22:27:38 -04:00
|
|
|
RSpec.describe UnicodeUsernameValidator do
|
2023-06-21 10:00:19 -04:00
|
|
|
subject(:validator) { described_class.new }
|
2019-04-23 06:22:47 -04:00
|
|
|
|
|
|
|
it "disallows Unicode usernames when external system avatars are disabled" do
|
|
|
|
SiteSetting.external_system_avatars_enabled = false
|
|
|
|
|
2023-06-21 10:00:19 -04:00
|
|
|
expect(validator.valid_value?("t")).to eq(false)
|
|
|
|
expect(validator.error_message).to eq(I18n.t("site_settings.errors.unicode_usernames_avatars"))
|
2019-04-23 06:22:47 -04:00
|
|
|
|
2023-06-21 10:00:19 -04:00
|
|
|
expect(validator.valid_value?("f")).to eq(true)
|
|
|
|
expect(validator.error_message).to be_blank
|
2019-04-23 06:22:47 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it "allows Unicode usernames when external system avatars are enabled" do
|
|
|
|
SiteSetting.external_system_avatars_enabled = true
|
|
|
|
|
2023-06-21 10:00:19 -04:00
|
|
|
expect(validator.valid_value?("t")).to eq(true)
|
|
|
|
expect(validator.error_message).to be_blank
|
2019-04-23 06:22:47 -04:00
|
|
|
|
2023-06-21 10:00:19 -04:00
|
|
|
expect(validator.valid_value?("f")).to eq(true)
|
|
|
|
expect(validator.error_message).to be_blank
|
2019-04-23 06:22:47 -04:00
|
|
|
end
|
|
|
|
end
|