Validate that Account#username is downcase
This commit is contained in:
parent
dc4857ce00
commit
cf104cb1b4
|
@ -1,7 +1,7 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class Account < ApplicationRecord
|
class Account < ApplicationRecord
|
||||||
USERNAME_RE = /\A[a-z][_a-z0-9]*[a-z0-9]\z/i.freeze
|
USERNAME_RE = /\A[a-z][_a-z0-9]*[a-z0-9]\z/.freeze
|
||||||
|
|
||||||
rolify role_join_table_name: :account_roles
|
rolify role_join_table_name: :account_roles
|
||||||
|
|
||||||
|
|
|
@ -60,6 +60,11 @@ RSpec.describe Account do
|
||||||
it { is_expected.to allow_value 'foo_bar' }
|
it { is_expected.to allow_value 'foo_bar' }
|
||||||
it { is_expected.to allow_value 'foo123' }
|
it { is_expected.to allow_value 'foo123' }
|
||||||
|
|
||||||
|
it do
|
||||||
|
is_expected.not_to \
|
||||||
|
allow_value Faker::Internet.username(3..36, %w[_]).upcase
|
||||||
|
end
|
||||||
|
|
||||||
it { is_expected.not_to allow_value Faker::Internet.email }
|
it { is_expected.not_to allow_value Faker::Internet.email }
|
||||||
it { is_expected.not_to allow_value '_foo' }
|
it { is_expected.not_to allow_value '_foo' }
|
||||||
it { is_expected.not_to allow_value 'bar_' }
|
it { is_expected.not_to allow_value 'bar_' }
|
||||||
|
|
Reference in New Issue