Spec: sign_in with instructeur.user
This commit is contained in:
parent
65a53909e1
commit
ad31822a68
14 changed files with 33 additions and 28 deletions
|
@ -49,7 +49,7 @@ class Users::PasswordsController < Devise::PasswordsController
|
|||
instructeur = Instructeur.find_by(email: current_user.email)
|
||||
|
||||
if instructeur
|
||||
sign_in instructeur
|
||||
sign_in(instructeur.user)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -11,7 +11,7 @@ describe Instructeurs::AvisController, type: :controller do
|
|||
let!(:avis_without_answer) { Avis.create(dossier: dossier, claimant: claimant, instructeur: instructeur) }
|
||||
let!(:avis_with_answer) { Avis.create(dossier: dossier, claimant: claimant, instructeur: instructeur, answer: 'yop') }
|
||||
|
||||
before { sign_in(instructeur) }
|
||||
before { sign_in(instructeur.user) }
|
||||
|
||||
describe '#index' do
|
||||
before { get :index }
|
||||
|
@ -217,7 +217,7 @@ describe Instructeurs::AvisController, type: :controller do
|
|||
|
||||
context 'when the instructeur is authenticated' do
|
||||
before do
|
||||
sign_in instructeur
|
||||
sign_in(instructeur.user)
|
||||
get :sign_up, params: { id: avis.id, email: invited_email }
|
||||
end
|
||||
|
||||
|
@ -238,7 +238,7 @@ describe Instructeurs::AvisController, type: :controller do
|
|||
let!(:avis) { create(:avis, email: invited_email, dossier: dossier) }
|
||||
|
||||
before do
|
||||
sign_in instructeur
|
||||
sign_in(instructeur.user)
|
||||
get :sign_up, params: { id: avis.id, email: invited_email }
|
||||
end
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ describe Instructeurs::DossiersController, type: :controller do
|
|||
let(:dossier) { create(:dossier, :en_construction, procedure: procedure) }
|
||||
let(:fake_justificatif) { Rack::Test::UploadedFile.new("./spec/fixtures/files/piece_justificative_0.pdf", 'application/pdf') }
|
||||
|
||||
before { sign_in(instructeur) }
|
||||
before { sign_in(instructeur.user) }
|
||||
|
||||
describe '#attestation' do
|
||||
context 'when a dossier has an attestation' do
|
||||
|
@ -110,7 +110,7 @@ describe Instructeurs::DossiersController, type: :controller do
|
|||
let(:dossier) { create(:dossier, :en_construction, procedure: procedure) }
|
||||
|
||||
before do
|
||||
sign_in instructeur
|
||||
sign_in(instructeur.user)
|
||||
post :passer_en_instruction, params: { procedure_id: procedure.id, dossier_id: dossier.id }, format: 'js'
|
||||
end
|
||||
|
||||
|
@ -133,7 +133,7 @@ describe Instructeurs::DossiersController, type: :controller do
|
|||
let(:dossier) { create(:dossier, :en_instruction, procedure: procedure) }
|
||||
|
||||
before do
|
||||
sign_in instructeur
|
||||
sign_in(instructeur.user)
|
||||
post :repasser_en_construction,
|
||||
params: { procedure_id: procedure.id, dossier_id: dossier.id },
|
||||
format: 'js'
|
||||
|
@ -155,7 +155,7 @@ describe Instructeurs::DossiersController, type: :controller do
|
|||
|
||||
describe '#repasser_en_instruction' do
|
||||
let(:dossier) { create(:dossier, :refuse, procedure: procedure) }
|
||||
let(:current_user) { instructeur }
|
||||
let(:current_user) { instructeur.user }
|
||||
|
||||
before do
|
||||
sign_in current_user
|
||||
|
@ -205,7 +205,7 @@ describe Instructeurs::DossiersController, type: :controller do
|
|||
context "with refuser" do
|
||||
before do
|
||||
dossier.en_instruction!
|
||||
sign_in instructeur
|
||||
sign_in(instructeur.user)
|
||||
end
|
||||
|
||||
context 'simple refusal' do
|
||||
|
@ -246,7 +246,7 @@ describe Instructeurs::DossiersController, type: :controller do
|
|||
context "with classer_sans_suite" do
|
||||
before do
|
||||
dossier.en_instruction!
|
||||
sign_in instructeur
|
||||
sign_in(instructeur.user)
|
||||
end
|
||||
context 'without attachment' do
|
||||
subject { post :terminer, params: { process_action: "classer_sans_suite", procedure_id: procedure.id, dossier_id: dossier.id }, format: 'js' }
|
||||
|
@ -288,7 +288,7 @@ describe Instructeurs::DossiersController, type: :controller do
|
|||
context "with accepter" do
|
||||
before do
|
||||
dossier.en_instruction!
|
||||
sign_in instructeur
|
||||
sign_in(instructeur.user)
|
||||
|
||||
expect(NotificationMailer).to receive(:send_closed_notification)
|
||||
.with(dossier)
|
||||
|
|
|
@ -93,7 +93,7 @@ describe Instructeurs::ProceduresController, type: :controller do
|
|||
end
|
||||
|
||||
context "when logged in" do
|
||||
before { sign_in(instructeur) }
|
||||
before { sign_in(instructeur.user) }
|
||||
|
||||
it { expect(response).to have_http_status(:ok) }
|
||||
|
||||
|
@ -171,7 +171,7 @@ describe Instructeurs::ProceduresController, type: :controller do
|
|||
|
||||
context "when logged in" do
|
||||
before do
|
||||
sign_in(instructeur)
|
||||
sign_in(instructeur.user)
|
||||
end
|
||||
|
||||
context "without anything" do
|
||||
|
@ -314,7 +314,7 @@ describe Instructeurs::ProceduresController, type: :controller do
|
|||
|
||||
context "when logged in" do
|
||||
before do
|
||||
sign_in(instructeur)
|
||||
sign_in(instructeur.user)
|
||||
end
|
||||
|
||||
context "csv" do
|
||||
|
@ -342,7 +342,7 @@ describe Instructeurs::ProceduresController, type: :controller do
|
|||
let!(:procedure) { create(:procedure, instructeurs: [instructeur]) }
|
||||
|
||||
context "when logged in" do
|
||||
before { sign_in(instructeur) }
|
||||
before { sign_in(instructeur.user) }
|
||||
|
||||
it { expect(instructeur.procedures_with_email_notifications).to be_empty }
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ describe Instructeurs::RechercheController, type: :controller do
|
|||
before { instructeur.procedures << dossier2.procedure }
|
||||
|
||||
describe 'GET #index' do
|
||||
before { sign_in instructeur }
|
||||
before { sign_in(instructeur.user) }
|
||||
|
||||
subject { get :index, params: { q: query } }
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ describe InvitesController, type: :controller do
|
|||
subject { post :create, params: { dossier_id: dossier.id, invite_email: email } }
|
||||
|
||||
context "when instructeur is signed_in" do
|
||||
let(:signed_in_profile) { create(:instructeur) }
|
||||
let(:signed_in_profile) { create(:instructeur).user }
|
||||
|
||||
shared_examples_for "he can not create invitation" do
|
||||
it { expect { subject rescue nil }.to change(Invite, :count).by(0) }
|
||||
|
@ -25,14 +25,14 @@ describe InvitesController, type: :controller do
|
|||
end
|
||||
|
||||
context 'when instructeur is invited for avis on dossier' do
|
||||
before { Avis.create(instructeur: signed_in_profile, claimant: create(:instructeur), dossier: dossier) }
|
||||
before { Avis.create(instructeur: signed_in_profile.instructeur, claimant: create(:instructeur), dossier: dossier) }
|
||||
|
||||
it_behaves_like "he can not create invitation"
|
||||
end
|
||||
|
||||
context 'when instructeur has access to dossier' do
|
||||
before do
|
||||
signed_in_profile.procedures << dossier.procedure
|
||||
signed_in_profile.instructeur.procedures << dossier.procedure
|
||||
end
|
||||
|
||||
it_behaves_like "he can not create invitation"
|
||||
|
|
|
@ -18,7 +18,7 @@ describe RootController, type: :controller do
|
|||
|
||||
before do
|
||||
instructeur.procedures << procedure
|
||||
sign_in instructeur
|
||||
sign_in(instructeur.user)
|
||||
end
|
||||
|
||||
it { expect(subject).to redirect_to(instructeur_procedures_path) }
|
||||
|
|
|
@ -12,6 +12,7 @@ describe Users::SessionsController, type: :controller do
|
|||
context "when the user is also a instructeur and an administrateur" do
|
||||
let!(:administrateur) { create(:administrateur, email: email, password: password) }
|
||||
let(:instructeur) { administrateur.instructeur }
|
||||
let(:user) { instructeur.user }
|
||||
let(:trusted_device) { true }
|
||||
let(:send_password) { password }
|
||||
|
||||
|
@ -73,6 +74,8 @@ describe Users::SessionsController, type: :controller do
|
|||
end
|
||||
|
||||
describe '#destroy' do
|
||||
let!(:user) { create(:user, email: email, password: password, loged_in_with_france_connect: loged_in_with_france_connect) }
|
||||
|
||||
before do
|
||||
sign_in user
|
||||
delete :destroy
|
||||
|
@ -145,7 +148,7 @@ describe Users::SessionsController, type: :controller do
|
|||
|
||||
before do
|
||||
if logged
|
||||
sign_in instructeur
|
||||
sign_in(instructeur.user)
|
||||
end
|
||||
allow(controller).to receive(:trust_device)
|
||||
allow(controller).to receive(:send_login_token_or_bufferize)
|
||||
|
|
|
@ -81,7 +81,7 @@ feature 'Getting help:' do
|
|||
let(:instructeur) { create(:instructeur) }
|
||||
|
||||
before do
|
||||
login_as instructeur, scope: :instructeur
|
||||
login_as instructeur.user, scope: :user
|
||||
end
|
||||
|
||||
scenario 'a Help menu is visible on signed-in pages' do
|
||||
|
|
|
@ -12,7 +12,7 @@ feature "procedure filters" do
|
|||
before do
|
||||
champ.update(value: "Mon champ rempli")
|
||||
champ_2.update(value: "Mon autre champ rempli différemment")
|
||||
login_as instructeur, scope: :instructeur
|
||||
login_as(instructeur.user, scope: :user)
|
||||
visit instructeur_procedure_path(procedure)
|
||||
end
|
||||
|
||||
|
|
|
@ -144,9 +144,9 @@ describe Instructeur, type: :model do
|
|||
context 'unified login' do
|
||||
it 'syncs credentials to associated administrateur' do
|
||||
admin = create(:administrateur)
|
||||
instructeur = admin.instructeur
|
||||
user = admin.instructeur.user
|
||||
|
||||
instructeur.update(password: 'démarches-simplifiées-pwd')
|
||||
user.update(password: 'démarches-simplifiées-pwd')
|
||||
|
||||
admin.reload
|
||||
expect(admin.valid_password?('démarches-simplifiées-pwd')).to be(true)
|
||||
|
|
|
@ -3,7 +3,7 @@ describe 'instructeurs/dossiers/show.html.haml', type: :view do
|
|||
let(:dossier) { create(:dossier, :en_construction) }
|
||||
|
||||
before do
|
||||
sign_in current_instructeur
|
||||
sign_in(current_instructeur.user)
|
||||
allow(view).to receive(:current_instructeur).and_return(current_instructeur)
|
||||
assign(:dossier, dossier)
|
||||
end
|
||||
|
|
|
@ -52,8 +52,10 @@ describe 'layouts/_new_header.html.haml', type: :view do
|
|||
end
|
||||
|
||||
context 'when rendering for instructeur' do
|
||||
let(:user) { create(:instructeur) }
|
||||
let(:instructeur) { create(:instructeur) }
|
||||
let(:user) { instructeur.user }
|
||||
let(:profile) { :instructeur }
|
||||
let(:current_instructeur) { instructeur }
|
||||
|
||||
it { is_expected.to have_css("a.header-logo[href=\"#{instructeur_procedures_path}\"]") }
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ describe 'shared/dossiers/demande.html.haml', type: :view do
|
|||
let(:dossier) { create(:dossier, :en_construction, procedure: procedure, etablissement: etablissement, individual: individual) }
|
||||
|
||||
before do
|
||||
sign_in current_instructeur
|
||||
sign_in(current_instructeur.user)
|
||||
end
|
||||
|
||||
subject! { render 'shared/dossiers/demande.html.haml', dossier: dossier, demande_seen_at: nil, profile: 'usager' }
|
||||
|
|
Loading…
Reference in a new issue