Feat(user): set email_verified_at when setting confirmed_at
This commit is contained in:
parent
841c1cc845
commit
fa06d17169
4 changed files with 19 additions and 3 deletions
|
@ -99,7 +99,7 @@ class User < ApplicationRecord
|
||||||
|
|
||||||
def self.create_or_promote_to_instructeur(email, password, administrateurs: [])
|
def self.create_or_promote_to_instructeur(email, password, administrateurs: [])
|
||||||
user = User
|
user = User
|
||||||
.create_with(password: password, confirmed_at: Time.zone.now)
|
.create_with(password: password, confirmed_at: Time.zone.now, email_verified_at: Time.zone.now)
|
||||||
.find_or_create_by(email: email)
|
.find_or_create_by(email: email)
|
||||||
|
|
||||||
if user.valid?
|
if user.valid?
|
||||||
|
@ -138,7 +138,7 @@ class User < ApplicationRecord
|
||||||
|
|
||||||
def self.create_or_promote_to_expert(email, password)
|
def self.create_or_promote_to_expert(email, password)
|
||||||
user = User
|
user = User
|
||||||
.create_with(password: password, confirmed_at: Time.zone.now)
|
.create_with(password: password, confirmed_at: Time.zone.now, email_verified_at: Time.zone.now)
|
||||||
.find_or_create_by(email: email)
|
.find_or_create_by(email: email)
|
||||||
|
|
||||||
if user.valid?
|
if user.valid?
|
||||||
|
|
|
@ -13,7 +13,8 @@ SuperAdmin.create!(email: default_user, password: default_password)
|
||||||
user = User.create!(
|
user = User.create!(
|
||||||
email: default_user,
|
email: default_user,
|
||||||
password: default_password,
|
password: default_password,
|
||||||
confirmed_at: Time.zone.now
|
confirmed_at: Time.zone.now,
|
||||||
|
email_verified_at: Time.zone.now
|
||||||
)
|
)
|
||||||
user.create_instructeur!
|
user.create_instructeur!
|
||||||
user.create_administrateur!
|
user.create_administrateur!
|
||||||
|
|
|
@ -19,6 +19,7 @@ describe FranceConnectInformation, type: :model do
|
||||||
it do
|
it do
|
||||||
subject
|
subject
|
||||||
expect(fci.user.email).to eq('a@email.com')
|
expect(fci.user.email).to eq('a@email.com')
|
||||||
|
expect(fci.user.email_verified_at).to be_present
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -117,6 +117,7 @@ describe User, type: :model do
|
||||||
user = subject
|
user = subject
|
||||||
expect(user.valid_password?(password)).to be true
|
expect(user.valid_password?(password)).to be true
|
||||||
expect(user.confirmed_at).to be_present
|
expect(user.confirmed_at).to be_present
|
||||||
|
expect(user.email_verified_at).to be_present
|
||||||
expect(user.instructeur).to be_present
|
expect(user.instructeur).to be_present
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -190,6 +191,7 @@ describe User, type: :model do
|
||||||
user = subject
|
user = subject
|
||||||
expect(user.valid_password?(password)).to be true
|
expect(user.valid_password?(password)).to be true
|
||||||
expect(user.confirmed_at).to be_present
|
expect(user.confirmed_at).to be_present
|
||||||
|
expect(user.email_verified_at).to be_present
|
||||||
expect(user.expert).to be_present
|
expect(user.expert).to be_present
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -220,6 +222,18 @@ describe User, type: :model do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe '.create_or_promote_to_gestionnaire' do
|
||||||
|
let(:email) { 'inst1@gmail.com' }
|
||||||
|
let(:password) { 'un super password !' }
|
||||||
|
|
||||||
|
subject { User.create_or_promote_to_gestionnaire(email, password) }
|
||||||
|
|
||||||
|
it 'verifies its email' do
|
||||||
|
user = subject
|
||||||
|
expect(user.email_verified_at).to be_present
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe 'invite_administrateur!' do
|
describe 'invite_administrateur!' do
|
||||||
let(:super_admin) { create(:super_admin) }
|
let(:super_admin) { create(:super_admin) }
|
||||||
let(:administrateur) { create(:administrateur) }
|
let(:administrateur) { create(:administrateur) }
|
||||||
|
|
Loading…
Reference in a new issue