mirror of
https://github.com/discourse/discourse.git
synced 2024-11-26 02:40:53 -06:00
4ea21fa2d0
This change both speeds up specs (less strings to allocate) and helps catch cases where methods in Discourse are mutating inputs. Overall we will be migrating everything to use #frozen_string_literal: true it will take a while, but this is the first and safest move in this direction
28 lines
852 B
Ruby
28 lines
852 B
Ruby
# frozen_string_literal: true
|
|
|
|
require 'rails_helper'
|
|
|
|
describe UnicodeUsernameValidator do
|
|
subject { described_class.new }
|
|
|
|
it "disallows Unicode usernames when external system avatars are disabled" do
|
|
SiteSetting.external_system_avatars_enabled = false
|
|
|
|
expect(subject.valid_value?("t")).to eq(false)
|
|
expect(subject.error_message).to eq(I18n.t("site_settings.errors.unicode_usernames_avatars"))
|
|
|
|
expect(subject.valid_value?("f")).to eq(true)
|
|
expect(subject.error_message).to be_blank
|
|
end
|
|
|
|
it "allows Unicode usernames when external system avatars are enabled" do
|
|
SiteSetting.external_system_avatars_enabled = true
|
|
|
|
expect(subject.valid_value?("t")).to eq(true)
|
|
expect(subject.error_message).to be_blank
|
|
|
|
expect(subject.valid_value?("f")).to eq(true)
|
|
expect(subject.error_message).to be_blank
|
|
end
|
|
end
|