Update instructeur factory
This commit is contained in:
parent
47b7dc368b
commit
65a53909e1
8 changed files with 33 additions and 13 deletions
|
@ -7,8 +7,8 @@ describe Users::PasswordsController, type: :controller do
|
|||
|
||||
describe "update" do
|
||||
context "unified login" do
|
||||
let(:user) { create(:user, email: 'unique@plop.com', password: 'mot de passe complexe') }
|
||||
let(:administrateur) { create(:administrateur, email: 'unique@plop.com', password: 'mot de passe complexe') }
|
||||
let(:user) { administrateur.instructeur.user }
|
||||
|
||||
before do
|
||||
@token = user.send(:set_reset_password_token)
|
||||
|
|
|
@ -104,7 +104,7 @@ describe Users::SessionsController, type: :controller do
|
|||
end
|
||||
|
||||
context "when associated administrateur" do
|
||||
let(:administrateur) { create(:administrateur, email: 'unique@plop.com') }
|
||||
let(:administrateur) { create(:administrateur, user: user) }
|
||||
|
||||
it 'signs user + instructeur + administrateur out' do
|
||||
sign_in user
|
||||
|
|
|
@ -4,8 +4,16 @@ FactoryBot.define do
|
|||
email { generate(:administrateur_email) }
|
||||
password { 'mon chien aime les bananes' }
|
||||
|
||||
after(:create) do |admin|
|
||||
create(:instructeur, email: admin.email, password: admin.password)
|
||||
transient do
|
||||
user { nil }
|
||||
end
|
||||
|
||||
after(:create) do |admin, evaluator|
|
||||
if evaluator.user.present?
|
||||
create(:instructeur, email: admin.email, password: admin.password, user: evaluator.user)
|
||||
else
|
||||
create(:instructeur, email: admin.email, password: admin.password)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -1,7 +1,21 @@
|
|||
FactoryBot.define do
|
||||
sequence(:instructeur_email) { |n| "gest#{n}@gest.com" }
|
||||
sequence(:instructeur_email) { |n| "inst#{n}@inst.com" }
|
||||
|
||||
factory :instructeur do
|
||||
email { generate(:instructeur_email) }
|
||||
password { 'démarches-simplifiées-pwd' }
|
||||
|
||||
transient do
|
||||
password { 'somethingverycomplated!' }
|
||||
end
|
||||
|
||||
after(:create) do |instructeur, evaluator|
|
||||
if evaluator.user.present?
|
||||
user = evaluator.user
|
||||
else
|
||||
user = create(:user, email: instructeur.email, password: evaluator.password)
|
||||
end
|
||||
|
||||
instructeur.update!(user: user)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -13,9 +13,7 @@ feature 'The instructeur part' do
|
|||
Flipflop::FeatureSet.current.test!.switch!(:enable_email_login_token, true)
|
||||
end
|
||||
|
||||
context 'when the instructeur is also a user' do
|
||||
let!(:user) { create(:user, email: instructeur.email, password: password) }
|
||||
|
||||
context 'the instructeur is also a user' do
|
||||
scenario 'a instructeur can fill a dossier' do
|
||||
visit commencer_path(path: procedure.path)
|
||||
click_on 'J’ai déjà un compte'
|
||||
|
|
|
@ -11,7 +11,7 @@ describe Administrateur, type: :model do
|
|||
context 'unified login' do
|
||||
it 'syncs credentials to associated user' do
|
||||
administrateur = create(:administrateur)
|
||||
user = create(:user, email: administrateur.email)
|
||||
user = administrateur.instructeur.user
|
||||
|
||||
administrateur.update(email: 'whoami@plop.com', password: 'voilà un super mdp')
|
||||
|
||||
|
|
|
@ -103,8 +103,8 @@ describe User, type: :model do
|
|||
|
||||
context 'unified login' do
|
||||
it 'syncs credentials to associated administrateur' do
|
||||
user = create(:user)
|
||||
admin = create(:administrateur, email: user.email)
|
||||
admin = create(:administrateur)
|
||||
user = admin.instructeur.user
|
||||
|
||||
user.update(email: 'whoami@plop.com', password: 'démarches-simplifiées2')
|
||||
user.confirm
|
||||
|
|
|
@ -28,6 +28,6 @@ describe 'admin/instructeurs/index.html.haml', type: :view do
|
|||
array: true))
|
||||
render
|
||||
end
|
||||
it { expect(rendered).to match(/gest\d+@gest.com/) }
|
||||
it { expect(rendered).to match(/inst\d+@inst.com/) }
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue