[fix 363] Dossier: remove next_step! action = initiate, role = user
This commit is contained in:
parent
907db89371
commit
201862d450
3 changed files with 4 additions and 27 deletions
|
@ -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
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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!
|
||||
|
|
Loading…
Add table
Reference in a new issue