[fix 363] Dossier: remove next_step! action = initiate, role = user

This commit is contained in:
Simon Lehericey 2017-12-05 17:12:56 +01:00 committed by LeSim
parent 907db89371
commit 201862d450
3 changed files with 4 additions and 27 deletions

View file

@ -10,7 +10,7 @@ class Users::RecapitulatifController < UsersController
def initiate
create_dossier_facade
@facade.dossier.next_step! 'user', 'initiate'
@facade.dossier.en_construction!
flash.notice = 'Dossier soumis avec succès.'
redirect_to users_dossier_recapitulatif_path

View file

@ -145,22 +145,15 @@ class Dossier < ActiveRecord::Base
end
def next_step! role, action, motivation = nil
unless %w(initiate receive refuse without_continuation close).include?(action)
unless %w(receive refuse without_continuation close).include?(action)
fail 'action is not valid'
end
unless %w(user gestionnaire).include?(role)
unless %w(gestionnaire).include?(role)
fail 'role is not valid'
end
case role
when 'user'
case action
when 'initiate'
if brouillon?
en_construction!
end
end
when 'gestionnaire'
case action
when 'close'

View file

@ -120,7 +120,7 @@ describe Dossier do
describe '#next_step' do
let(:dossier) { create(:dossier) }
let(:role) { 'user' }
let(:action) { 'initiate' }
let(:action) { 'receive' }
subject { dossier.next_step! role, action }
@ -134,22 +134,6 @@ describe Dossier do
it { expect { subject }.to raise_error('role is not valid') }
end
context 'when dossier is at state brouillon' do
before do
dossier.brouillon!
end
context 'when user is connected' do
let(:role) { 'user' }
context 'when he initiate a dossier' do
let(:action) { 'initiate' }
it { is_expected.to eq('en_construction') }
end
end
end
context 'when dossier is at state en_instruction' do
before do
dossier.en_instruction!