From 201862d450919062bfe3011298a23949d3bfa872 Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Tue, 5 Dec 2017 17:12:56 +0100 Subject: [PATCH] [fix 363] Dossier: remove next_step! action = initiate, role = user --- .../users/recapitulatif_controller.rb | 2 +- app/models/dossier.rb | 11 ++--------- spec/models/dossier_spec.rb | 18 +----------------- 3 files changed, 4 insertions(+), 27 deletions(-) diff --git a/app/controllers/users/recapitulatif_controller.rb b/app/controllers/users/recapitulatif_controller.rb index 6d4aac291..bdd1df237 100644 --- a/app/controllers/users/recapitulatif_controller.rb +++ b/app/controllers/users/recapitulatif_controller.rb @@ -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 diff --git a/app/models/dossier.rb b/app/models/dossier.rb index e602d25e0..7c06ae1ba 100644 --- a/app/models/dossier.rb +++ b/app/models/dossier.rb @@ -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' diff --git a/spec/models/dossier_spec.rb b/spec/models/dossier_spec.rb index 9961aa184..5b1b886a4 100644 --- a/spec/models/dossier_spec.rb +++ b/spec/models/dossier_spec.rb @@ -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!