[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
|
def initiate
|
||||||
create_dossier_facade
|
create_dossier_facade
|
||||||
|
|
||||||
@facade.dossier.next_step! 'user', 'initiate'
|
@facade.dossier.en_construction!
|
||||||
flash.notice = 'Dossier soumis avec succès.'
|
flash.notice = 'Dossier soumis avec succès.'
|
||||||
|
|
||||||
redirect_to users_dossier_recapitulatif_path
|
redirect_to users_dossier_recapitulatif_path
|
||||||
|
|
|
@ -145,22 +145,15 @@ class Dossier < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def next_step! role, action, motivation = nil
|
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'
|
fail 'action is not valid'
|
||||||
end
|
end
|
||||||
|
|
||||||
unless %w(user gestionnaire).include?(role)
|
unless %w(gestionnaire).include?(role)
|
||||||
fail 'role is not valid'
|
fail 'role is not valid'
|
||||||
end
|
end
|
||||||
|
|
||||||
case role
|
case role
|
||||||
when 'user'
|
|
||||||
case action
|
|
||||||
when 'initiate'
|
|
||||||
if brouillon?
|
|
||||||
en_construction!
|
|
||||||
end
|
|
||||||
end
|
|
||||||
when 'gestionnaire'
|
when 'gestionnaire'
|
||||||
case action
|
case action
|
||||||
when 'close'
|
when 'close'
|
||||||
|
|
|
@ -120,7 +120,7 @@ describe Dossier do
|
||||||
describe '#next_step' do
|
describe '#next_step' do
|
||||||
let(:dossier) { create(:dossier) }
|
let(:dossier) { create(:dossier) }
|
||||||
let(:role) { 'user' }
|
let(:role) { 'user' }
|
||||||
let(:action) { 'initiate' }
|
let(:action) { 'receive' }
|
||||||
|
|
||||||
subject { dossier.next_step! role, action }
|
subject { dossier.next_step! role, action }
|
||||||
|
|
||||||
|
@ -134,22 +134,6 @@ describe Dossier do
|
||||||
it { expect { subject }.to raise_error('role is not valid') }
|
it { expect { subject }.to raise_error('role is not valid') }
|
||||||
end
|
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
|
context 'when dossier is at state en_instruction' do
|
||||||
before do
|
before do
|
||||||
dossier.en_instruction!
|
dossier.en_instruction!
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue