2018-08-07 16:32:11 +02:00
|
|
|
describe 'Dossier details:' do
|
|
|
|
let(:user) { create(:user) }
|
2018-08-14 15:06:44 +02:00
|
|
|
let(:simple_procedure) do
|
|
|
|
tdcs = [create(:type_de_champ, libelle: 'texte obligatoire')]
|
|
|
|
create(:procedure, :published, :for_individual, types_de_champ: tdcs)
|
|
|
|
end
|
|
|
|
let(:dossier) { create(:dossier, :en_construction, :for_individual, user: user, procedure: simple_procedure) }
|
2018-08-07 16:32:11 +02:00
|
|
|
|
|
|
|
before do
|
|
|
|
Flipflop::FeatureSet.current.test!.switch!(:new_dossier_details, true)
|
|
|
|
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
|
|
|
visit_dossier dossier
|
|
|
|
|
|
|
|
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-08-07 16:32:11 +02:00
|
|
|
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-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
|