1
0
Fork 0

Validate that Account#username is downcase

This commit is contained in:
Alex Kotov 2019-02-01 06:33:08 +05:00
parent dc4857ce00
commit cf104cb1b4
Signed by: kotovalexarian
GPG Key ID: 553C0EBBEB5D5F08
2 changed files with 6 additions and 1 deletions

View File

@ -1,7 +1,7 @@
# frozen_string_literal: true
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

View File

@ -60,6 +60,11 @@ RSpec.describe Account do
it { is_expected.to allow_value 'foo_bar' }
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 '_foo' }
it { is_expected.not_to allow_value 'bar_' }