2018-08-07 16:32:11 +02:00
|
|
|
|
describe 'Dossier details:' do
|
|
|
|
|
let(:user) { create(:user) }
|
2018-09-24 15:54:46 +02:00
|
|
|
|
let(:procedure) { create(:simple_procedure) }
|
|
|
|
|
let(:dossier) { create(:dossier, :en_construction, :for_individual, :with_commentaires, user: user, procedure: procedure) }
|
2018-08-07 16:32:11 +02:00
|
|
|
|
|
|
|
|
|
before do
|
|
|
|
|
Flipflop::FeatureSet.current.test!.switch!(:new_dossier_details, true)
|
2018-09-25 11:24:41 +02:00
|
|
|
|
visit_dossier dossier
|
2018-08-07 16:32:11 +02:00
|
|
|
|
end
|
|
|
|
|
|
2018-08-10 16:17:19 +02:00
|
|
|
|
scenario 'the user can see the summary of the dossier status' do
|
2018-08-07 16:32:11 +02:00
|
|
|
|
expect(page).to have_current_path(dossier_path(dossier))
|
|
|
|
|
expect(page).to have_content(dossier.id)
|
2018-08-10 16:17:19 +02:00
|
|
|
|
expect(page).to have_selector('.status-explanation')
|
2018-09-11 18:40:10 +02:00
|
|
|
|
expect(page).to have_text(dossier.commentaires.last.body)
|
2018-08-07 16:32:11 +02:00
|
|
|
|
end
|
|
|
|
|
|
2018-09-18 17:45:24 +02:00
|
|
|
|
describe "the user can see the mean time they are expected to wait" do
|
2018-09-25 11:24:41 +02:00
|
|
|
|
context "when the dossier is in construction" do
|
2018-09-18 17:47:41 +02:00
|
|
|
|
before do
|
2018-09-24 15:54:46 +02:00
|
|
|
|
other_dossier = create(:dossier, :accepte, :for_individual, procedure: procedure, en_construction_at: 10.days.ago, en_instruction_at: Time.now)
|
2018-09-25 11:24:41 +02:00
|
|
|
|
visit dossier_path(dossier)
|
2018-09-18 17:47:41 +02:00
|
|
|
|
end
|
|
|
|
|
|
2018-09-25 11:24:41 +02:00
|
|
|
|
it { expect(page).to have_text("Le temps moyen de vérification pour cette démarche est de 10 jours.") }
|
2018-09-18 17:47:41 +02:00
|
|
|
|
end
|
|
|
|
|
|
2018-09-25 11:24:41 +02:00
|
|
|
|
context "when the dossier is in instruction" do
|
2018-09-24 15:54:46 +02:00
|
|
|
|
let(:dossier) { create(:dossier, :en_instruction, :for_individual, :with_commentaires, user: user, procedure: procedure) }
|
2018-09-18 17:45:24 +02:00
|
|
|
|
|
|
|
|
|
before do
|
2018-09-24 15:54:46 +02:00
|
|
|
|
other_dossier = create(:dossier, :accepte, :for_individual, procedure: procedure, en_instruction_at: 2.months.ago, processed_at: Time.now)
|
2018-09-25 11:24:41 +02:00
|
|
|
|
visit dossier_path(dossier)
|
2018-09-18 17:45:24 +02:00
|
|
|
|
end
|
|
|
|
|
|
2018-09-25 11:24:41 +02:00
|
|
|
|
it { expect(page).to have_text("Le temps moyen d’instruction pour cette démarche est de 2 mois.") }
|
2018-09-18 17:45:24 +02:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2018-08-14 15:06:44 +02:00
|
|
|
|
scenario 'the user can see and edit dossier before instruction' do
|
|
|
|
|
visit_dossier dossier
|
2018-08-29 16:57:01 +02:00
|
|
|
|
click_on 'Demande'
|
2018-08-14 15:06:44 +02:00
|
|
|
|
|
2018-08-29 16:57:01 +02:00
|
|
|
|
expect(page).to have_current_path(demande_dossier_path(dossier))
|
2018-08-14 15:06:44 +02:00
|
|
|
|
click_on 'Modifier le dossier'
|
|
|
|
|
|
|
|
|
|
expect(page).to have_current_path(modifier_dossier_path(dossier))
|
|
|
|
|
fill_in('texte obligatoire', with: 'Nouveau texte')
|
|
|
|
|
click_on 'Enregistrer les modifications du dossier'
|
|
|
|
|
|
2018-08-29 16:57:01 +02:00
|
|
|
|
expect(page).to have_current_path(demande_dossier_path(dossier))
|
2018-08-14 15:06:44 +02:00
|
|
|
|
expect(page).to have_content('Nouveau texte')
|
|
|
|
|
end
|
|
|
|
|
|
2018-09-05 13:56:12 +02:00
|
|
|
|
context 'with messages' do
|
|
|
|
|
let!(:commentaire) { create(:commentaire, dossier: dossier, email: 'instructeur@exemple.fr', body: 'Message envoyé à l’usager') }
|
|
|
|
|
let(:message_body) { 'Message envoyé à l’instructeur' }
|
|
|
|
|
|
|
|
|
|
scenario 'the user can send a message' do
|
|
|
|
|
visit_dossier dossier
|
|
|
|
|
click_on 'Messagerie'
|
|
|
|
|
|
|
|
|
|
expect(page).to have_current_path(messagerie_dossier_path(dossier))
|
|
|
|
|
expect(page).to have_content(commentaire.body)
|
|
|
|
|
|
|
|
|
|
fill_in 'commentaire_body', with: message_body
|
|
|
|
|
click_on 'Envoyer'
|
|
|
|
|
|
|
|
|
|
expect(page).to have_current_path(messagerie_dossier_path(dossier))
|
|
|
|
|
expect(page).to have_content('Message envoyé')
|
|
|
|
|
expect(page).to have_content(commentaire.body)
|
|
|
|
|
expect(page).to have_content(message_body)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2018-08-07 16:32:11 +02:00
|
|
|
|
private
|
|
|
|
|
|
|
|
|
|
def visit_dossier(dossier)
|
|
|
|
|
visit dossier_path(dossier)
|
|
|
|
|
|
|
|
|
|
expect(page).to have_current_path(new_user_session_path)
|
|
|
|
|
fill_in 'user_email', with: user.email
|
|
|
|
|
fill_in 'user_password', with: user.password
|
|
|
|
|
click_on 'Se connecter'
|
|
|
|
|
|
|
|
|
|
expect(page).to have_current_path(dossier_path(dossier))
|
|
|
|
|
end
|
|
|
|
|
end
|