DossierController#update → #update_brouillon
This commit is contained in:
parent
5ac8117c69
commit
338ffb8b50
5 changed files with 12 additions and 12 deletions
|
@ -4,10 +4,10 @@ module NewUser
|
||||||
|
|
||||||
helper_method :new_demarche_url
|
helper_method :new_demarche_url
|
||||||
|
|
||||||
before_action :ensure_ownership!, except: [:index, :show, :demande, :messagerie, :brouillon, :update, :recherche]
|
before_action :ensure_ownership!, except: [:index, :show, :demande, :messagerie, :brouillon, :update_brouillon, :recherche]
|
||||||
before_action :ensure_ownership_or_invitation!, only: [:show, :demande, :messagerie, :brouillon, :update, :create_commentaire]
|
before_action :ensure_ownership_or_invitation!, only: [:show, :demande, :messagerie, :brouillon, :update_brouillon, :create_commentaire]
|
||||||
before_action :ensure_dossier_can_be_updated, only: [:update_identite, :update]
|
before_action :ensure_dossier_can_be_updated, only: [:update_identite, :update_brouillon]
|
||||||
before_action :forbid_invite_submission!, only: [:update]
|
before_action :forbid_invite_submission!, only: [:update_brouillon]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@user_dossiers = current_user.dossiers.includes(:procedure).order_by_updated_at.page(page)
|
@user_dossiers = current_user.dossiers.includes(:procedure).order_by_updated_at.page(page)
|
||||||
|
@ -87,7 +87,7 @@ module NewUser
|
||||||
|
|
||||||
# FIXME: remove PiecesJustificativesService
|
# FIXME: remove PiecesJustificativesService
|
||||||
# delegate draft save logic to champ ?
|
# delegate draft save logic to champ ?
|
||||||
def update
|
def update_brouillon
|
||||||
@dossier = dossier_with_champs
|
@dossier = dossier_with_champs
|
||||||
|
|
||||||
errors = PiecesJustificativesService.upload!(@dossier, current_user, params)
|
errors = PiecesJustificativesService.upload!(@dossier, current_user, params)
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
- if apercu
|
- if apercu
|
||||||
- form_options = { url: '', method: :get, html: { class: 'form', multipart: true } }
|
- form_options = { url: '', method: :get, html: { class: 'form', multipart: true } }
|
||||||
- else
|
- else
|
||||||
- form_options = { url: modifier_dossier_url(dossier), method: :patch, html: { class: 'form', multipart: true } }
|
- form_options = { url: brouillon_dossier_url(dossier), method: :patch, html: { class: 'form', multipart: true } }
|
||||||
|
|
||||||
= form_for dossier, form_options do |f|
|
= form_for dossier, form_options do |f|
|
||||||
|
|
||||||
|
|
|
@ -276,7 +276,7 @@ Rails.application.routes.draw do
|
||||||
get 'identite'
|
get 'identite'
|
||||||
patch 'update_identite'
|
patch 'update_identite'
|
||||||
get 'brouillon'
|
get 'brouillon'
|
||||||
patch 'modifier', to: 'dossiers#update', as: 'modifier'
|
patch 'brouillon', to: 'dossiers#update_brouillon'
|
||||||
get 'merci'
|
get 'merci'
|
||||||
get 'demande'
|
get 'demande'
|
||||||
get 'messagerie'
|
get 'messagerie'
|
||||||
|
|
|
@ -243,7 +243,7 @@ describe NewUser::DossiersController, type: :controller do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#update' do
|
describe '#update_brouillon' do
|
||||||
before { sign_in(user) }
|
before { sign_in(user) }
|
||||||
let!(:dossier) { create(:dossier, user: user) }
|
let!(:dossier) { create(:dossier, user: user) }
|
||||||
let(:first_champ) { dossier.champs.first }
|
let(:first_champ) { dossier.champs.first }
|
||||||
|
@ -261,7 +261,7 @@ describe NewUser::DossiersController, type: :controller do
|
||||||
end
|
end
|
||||||
let(:payload) { submit_payload }
|
let(:payload) { submit_payload }
|
||||||
|
|
||||||
subject { patch :update, params: payload }
|
subject { patch :update_brouillon, params: payload }
|
||||||
|
|
||||||
context 'when the dossier cannot be updated by the user' do
|
context 'when the dossier cannot be updated by the user' do
|
||||||
let!(:dossier) { create(:dossier, :en_instruction, user: user) }
|
let!(:dossier) { create(:dossier, :en_instruction, user: user) }
|
||||||
|
@ -295,7 +295,7 @@ describe NewUser::DossiersController, type: :controller do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'sends an email only on the first #update' do
|
it 'sends an email only on the first #update_brouillon' do
|
||||||
delivery = double
|
delivery = double
|
||||||
expect(delivery).to receive(:deliver_later).with(no_args)
|
expect(delivery).to receive(:deliver_later).with(no_args)
|
||||||
|
|
||||||
|
|
|
@ -96,12 +96,12 @@ feature 'The user' do
|
||||||
click_on 'Enregistrer le brouillon'
|
click_on 'Enregistrer le brouillon'
|
||||||
expect(user_dossier.reload.brouillon?).to be(true)
|
expect(user_dossier.reload.brouillon?).to be(true)
|
||||||
expect(page).to have_content('Votre brouillon a bien été sauvegardé')
|
expect(page).to have_content('Votre brouillon a bien été sauvegardé')
|
||||||
expect(page).to have_current_path(modifier_dossier_path(user_dossier))
|
expect(page).to have_current_path(brouillon_dossier_path(user_dossier))
|
||||||
|
|
||||||
# Check an incomplete dossier cannot be submitted when mandatory fields are missing
|
# Check an incomplete dossier cannot be submitted when mandatory fields are missing
|
||||||
click_on 'Soumettre le dossier'
|
click_on 'Soumettre le dossier'
|
||||||
expect(user_dossier.reload.brouillon?).to be(true)
|
expect(user_dossier.reload.brouillon?).to be(true)
|
||||||
expect(page).to have_current_path(modifier_dossier_path(user_dossier))
|
expect(page).to have_current_path(brouillon_dossier_path(user_dossier))
|
||||||
|
|
||||||
# Check a dossier can be submitted when all mandatory fields are filled
|
# Check a dossier can be submitted when all mandatory fields are filled
|
||||||
fill_in('texte obligatoire', with: 'super texte')
|
fill_in('texte obligatoire', with: 'super texte')
|
||||||
|
|
Loading…
Reference in a new issue