-
-
Notifications
You must be signed in to change notification settings - Fork 913
Description
Hello everything is fine? I'm having some problems doing unique validations with the gem following my models and tests.
Model User
validates :name, :username, :email, :password_digest, presence: true validates :email, :username, uniqueness: { case_sensitive: false }
Model Phone
validates :phone_type, :phone_number, presence: true validates :phone_number, uniqueness: { case_sensitive: false }
Spec User
it { is_expected.to validate_presence_of(:email) } it { is_expected.to validate_uniqueness_of(:email).case_insensitive } it { is_expected.to validate_presence_of(:username) } it { is_expected.to validate_uniqueness_of(:username).case_insensitive }
Spec Phone
it { is_expected.to validate_presence_of(:phone_number) } it { is_expected.to validate_uniqueness_of(:phone_number).case_insensitive }
My factories
User
factory :user do name { Faker::Name.name } email { Faker::Internet.email } password_digest { Faker::Internet.password(min_length: 8) } token_password_recovery { rand(1..999) } token_password_recovery_deadline { '2023-06-17 15:28:41' } token_password_confirmation { rand(1..999) } token_password_confirmation_deadline { '2023-06-17 15:28:41' } company username { Faker::Internet.username } end
Phone
factory :phone do phone_type { rand(0..1) } phone_number { Faker::PhoneNumber.phone_number_with_country_code } after :build, &:phoneble end


