From c8409ecb896b5cbb7f2af750e74cf27e00c7ecf7 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Tue, 31 Jul 2018 13:33:50 +0000 Subject: [PATCH] dossier: remove route hack for show --- app/views/shared/dossiers/_edit.html.haml | 2 +- config/routes.rb | 4 +--- spec/features/new_user/dossier_spec.rb | 4 ++-- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/app/views/shared/dossiers/_edit.html.haml b/app/views/shared/dossiers/_edit.html.haml index c43012547..2c83362b3 100644 --- a/app/views/shared/dossiers/_edit.html.haml +++ b/app/views/shared/dossiers/_edit.html.haml @@ -4,7 +4,7 @@ - if apercu - form_options = { url: '', method: :get, html: { class: 'form', multipart: true } } - else - - form_options = { html: { class: 'form', multipart: true, novalidate: dossier.brouillon? } } + - form_options = { url: modifier_dossier_url(dossier), method: :patch, html: { class: 'form', multipart: true, novalidate: dossier.brouillon? } } = form_for dossier, form_options do |f| diff --git a/config/routes.rb b/config/routes.rb index 663a9562f..ba3d88bb0 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -243,6 +243,7 @@ Rails.application.routes.draw do get 'identite' patch 'update_identite' get 'modifier' + patch 'modifier', to: 'dossiers#update' get 'merci' post 'ask_deletion' get 'attestation' @@ -250,9 +251,6 @@ Rails.application.routes.draw do collection do post 'recherche' - # FIXME: to remove when show is implemeted - # needed to fix refresh after dossier draft save - get ':id', to: redirect('/dossiers/%{id}/modifier') end end end diff --git a/spec/features/new_user/dossier_spec.rb b/spec/features/new_user/dossier_spec.rb index 4b8100e65..4859ed215 100644 --- a/spec/features/new_user/dossier_spec.rb +++ b/spec/features/new_user/dossier_spec.rb @@ -96,12 +96,12 @@ feature 'The user' do click_on 'Enregistrer le brouillon' expect(user_dossier.reload.brouillon?).to be(true) expect(page).to have_content('Votre brouillon a bien été sauvegardé') - expect(page).to have_current_path(dossier_path(user_dossier)) + expect(page).to have_current_path(modifier_dossier_path(user_dossier)) # Check an incomplete dossier cannot be submitted when mandatory fields are missing click_on 'Soumettre le dossier' expect(user_dossier.reload.brouillon?).to be(true) - expect(page).to have_current_path(dossier_path(user_dossier)) + expect(page).to have_current_path(modifier_dossier_path(user_dossier)) # Check a dossier can be submitted when all mandatory fields are filled fill_in('texte obligatoire', with: 'super texte')