tests
This commit is contained in:
parent
39d0dd2af1
commit
8a1cdf31e3
4 changed files with 59 additions and 10 deletions
|
@ -159,7 +159,7 @@ describe Experts::AvisController, type: :controller do
|
||||||
let(:previous_avis_confidentiel) { false }
|
let(:previous_avis_confidentiel) { false }
|
||||||
let(:asked_confidentiel) { false }
|
let(:asked_confidentiel) { false }
|
||||||
let(:intro) { 'introduction' }
|
let(:intro) { 'introduction' }
|
||||||
let(:emails) { ["toto@totomail.com"] }
|
let(:emails) { "[\"toto@totomail.com\"]" }
|
||||||
let(:invite_linked_dossiers) { nil }
|
let(:invite_linked_dossiers) { nil }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
|
@ -176,7 +176,7 @@ describe Experts::AvisController, type: :controller do
|
||||||
|
|
||||||
describe '#create_avis' do
|
describe '#create_avis' do
|
||||||
let!(:previous_avis) { create(:avis, dossier: dossier, claimant: claimant, experts_procedure: experts_procedure, confidentiel: previous_avis_confidentiel) }
|
let!(:previous_avis) { create(:avis, dossier: dossier, claimant: claimant, experts_procedure: experts_procedure, confidentiel: previous_avis_confidentiel) }
|
||||||
let(:emails) { ['a@b.com'] }
|
let(:emails) { "[\"a@b.com\"]" }
|
||||||
let(:intro) { 'introduction' }
|
let(:intro) { 'introduction' }
|
||||||
let(:created_avis) { Avis.last }
|
let(:created_avis) { Avis.last }
|
||||||
let!(:old_avis_count) { Avis.count }
|
let!(:old_avis_count) { Avis.count }
|
||||||
|
@ -194,7 +194,7 @@ describe Experts::AvisController, type: :controller do
|
||||||
context 'when an invalid email' do
|
context 'when an invalid email' do
|
||||||
let(:previous_avis_confidentiel) { false }
|
let(:previous_avis_confidentiel) { false }
|
||||||
let(:asked_confidentiel) { false }
|
let(:asked_confidentiel) { false }
|
||||||
let(:emails) { ["toto.fr"] }
|
let(:emails) { "[\"toto.fr\"]" }
|
||||||
|
|
||||||
it { expect(response).to render_template :instruction }
|
it { expect(response).to render_template :instruction }
|
||||||
it { expect(flash.alert).to eq(["toto.fr : Email n'est pas valide"]) }
|
it { expect(flash.alert).to eq(["toto.fr : Email n'est pas valide"]) }
|
||||||
|
@ -205,7 +205,7 @@ describe Experts::AvisController, type: :controller do
|
||||||
context 'ask review with attachment' do
|
context 'ask review with attachment' do
|
||||||
let(:previous_avis_confidentiel) { false }
|
let(:previous_avis_confidentiel) { false }
|
||||||
let(:asked_confidentiel) { false }
|
let(:asked_confidentiel) { false }
|
||||||
let(:emails) { ["toto@totomail.com"] }
|
let(:emails) { "[\"toto@totomail.com\"]" }
|
||||||
|
|
||||||
it { expect(created_avis.introduction_file).to be_attached }
|
it { expect(created_avis.introduction_file).to be_attached }
|
||||||
it { expect(created_avis.introduction_file.filename).to eq("piece_justificative_0.pdf") }
|
it { expect(created_avis.introduction_file.filename).to eq("piece_justificative_0.pdf") }
|
||||||
|
@ -216,7 +216,7 @@ describe Experts::AvisController, type: :controller do
|
||||||
context 'with multiple emails' do
|
context 'with multiple emails' do
|
||||||
let(:asked_confidentiel) { false }
|
let(:asked_confidentiel) { false }
|
||||||
let(:previous_avis_confidentiel) { false }
|
let(:previous_avis_confidentiel) { false }
|
||||||
let(:emails) { ["toto.fr,titi@titimail.com"] }
|
let(:emails) { "[\"toto.fr\",\"titi@titimail.com\"]" }
|
||||||
|
|
||||||
it { expect(response).to render_template :instruction }
|
it { expect(response).to render_template :instruction }
|
||||||
it { expect(flash.alert).to eq(["toto.fr : Email n'est pas valide"]) }
|
it { expect(flash.alert).to eq(["toto.fr : Email n'est pas valide"]) }
|
||||||
|
|
|
@ -448,7 +448,7 @@ describe Instructeurs::DossiersController, type: :controller do
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
let(:emails) { ['email@a.com'] }
|
let(:emails) { "[\"email@a.com\"]" }
|
||||||
|
|
||||||
context "notifications updates" do
|
context "notifications updates" do
|
||||||
context 'when an instructeur follows the dossier' do
|
context 'when an instructeur follows the dossier' do
|
||||||
|
@ -476,7 +476,7 @@ describe Instructeurs::DossiersController, type: :controller do
|
||||||
it { expect(response).to redirect_to(avis_instructeur_dossier_path(dossier.procedure, dossier)) }
|
it { expect(response).to redirect_to(avis_instructeur_dossier_path(dossier.procedure, dossier)) }
|
||||||
|
|
||||||
context "with an invalid email" do
|
context "with an invalid email" do
|
||||||
let(:emails) { ['emaila.com'] }
|
let(:emails) { "[\"emaila.com\"]" }
|
||||||
|
|
||||||
before { subject }
|
before { subject }
|
||||||
|
|
||||||
|
@ -487,7 +487,7 @@ describe Instructeurs::DossiersController, type: :controller do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with multiple emails' do
|
context 'with multiple emails' do
|
||||||
let(:emails) { ["toto.fr,titi@titimail.com"] }
|
let(:emails) { "[\"toto.fr\",\"titi@titimail.com\"]" }
|
||||||
|
|
||||||
before { subject }
|
before { subject }
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,49 @@
|
||||||
|
describe NewAdministrateur::ExpertsProceduresController, type: :controller do
|
||||||
|
let(:admin) { create(:administrateur) }
|
||||||
|
|
||||||
|
before do
|
||||||
|
sign_in(admin.user)
|
||||||
|
end
|
||||||
|
describe '#add_expert_to_procedure' do
|
||||||
|
let(:procedure) { create :procedure, administrateur: admin }
|
||||||
|
let(:expert) { create(:expert) }
|
||||||
|
let(:expert2) { create(:expert) }
|
||||||
|
|
||||||
|
subject do
|
||||||
|
post :add_expert_to_procedure,
|
||||||
|
params: { procedure_id: procedure.id, emails: "[\"#{expert.email}\",\"#{expert2.email}\"]" }
|
||||||
|
end
|
||||||
|
|
||||||
|
before do
|
||||||
|
subject
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'of multiple experts' do
|
||||||
|
it { expect(procedure.experts.include?(expert)).to be_truthy }
|
||||||
|
it { expect(procedure.experts.include?(expert2)).to be_truthy }
|
||||||
|
it { expect(flash.notice).to be_present }
|
||||||
|
it { expect(response).to redirect_to(admin_procedure_invited_expert_list_path(procedure)) }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe '#revoke_expert_from_procedure' do
|
||||||
|
let(:procedure) { create :procedure, administrateur: admin }
|
||||||
|
let(:expert) { create(:expert) }
|
||||||
|
let(:expert_procedure) { ExpertsProcedure.create(expert: expert, procedure: procedure) }
|
||||||
|
|
||||||
|
subject do
|
||||||
|
put :revoke_expert_from_procedure, params: { procedure_id: procedure.id, expert_procedure: { id: expert_procedure.id } }
|
||||||
|
end
|
||||||
|
|
||||||
|
before do
|
||||||
|
subject
|
||||||
|
expert_procedure.reload
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'of multiple experts' do
|
||||||
|
it { expect(expert_procedure.revoked_at).to be_present }
|
||||||
|
it { expect(flash.notice).to be_present }
|
||||||
|
it { expect(response).to redirect_to(admin_procedure_invited_expert_list_path(procedure)) }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,4 +1,4 @@
|
||||||
feature 'Inviting an expert:' do
|
feature 'Inviting an expert:', js: true do
|
||||||
include ActiveJob::TestHelper
|
include ActiveJob::TestHelper
|
||||||
include ActionView::Helpers
|
include ActionView::Helpers
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ feature 'Inviting an expert:' do
|
||||||
click_on 'Avis externes'
|
click_on 'Avis externes'
|
||||||
expect(page).to have_current_path(avis_instructeur_dossier_path(procedure, dossier))
|
expect(page).to have_current_path(avis_instructeur_dossier_path(procedure, dossier))
|
||||||
|
|
||||||
fill_in 'avis_emails', with: "#{expert.email}, #{expert2.email}"
|
page.execute_script("document.querySelector('#avis_emails').value = '[\"#{expert.email}\",\"#{expert2.email}\"]'")
|
||||||
fill_in 'avis_introduction', with: 'Bonjour, merci de me donner votre avis sur ce dossier.'
|
fill_in 'avis_introduction', with: 'Bonjour, merci de me donner votre avis sur ce dossier.'
|
||||||
check 'avis_invite_linked_dossiers'
|
check 'avis_invite_linked_dossiers'
|
||||||
page.select 'confidentiel', from: 'avis_confidentiel'
|
page.select 'confidentiel', from: 'avis_confidentiel'
|
||||||
|
|
Loading…
Reference in a new issue