REFACTOR : Change dossier state 'Deposited' To 'SubmitValidated'

This commit is contained in:
Xavier J 2015-11-02 11:52:39 +01:00
parent da8c166331
commit 76d87c7f79
14 changed files with 40 additions and 35 deletions

View file

@ -25,10 +25,10 @@ class Users::RecapitulatifController < UsersController
render 'show'
end
def depose
def submit_validate
show
@dossier.next_step! 'user', 'depose'
@dossier.next_step! 'user', 'submit_validate'
flash.notice = 'Dossier déposé avec succès.'
render 'show'

View file

@ -23,7 +23,7 @@ class DossierDecorator < Draper::Decorator
'Mis à jour'
when 'validated'
'Validé'
when 'deposited'
when 'submit_validated'
'Déposé'
when 'processed'
'Traité'

View file

@ -3,8 +3,8 @@ class Dossier < ActiveRecord::Base
submitted: 'submitted',
replied: 'replied',
updated: 'updated',
validated: 'validated', #-confirmed
deposited: 'deposited', #submit_validated
validated: 'validated',
submit_validated: 'submit_validated', #deposited
processed: 'processed'} #closed
has_one :etablissement, dependent: :destroy
@ -49,7 +49,7 @@ class Dossier < ActiveRecord::Base
end
def next_step! role, action
unless %w(submit replied update comment valid depose process).include?(action)
unless %w(submit replied update comment valid submit_validate process).include?(action)
fail 'action is not valid'
end
@ -63,9 +63,9 @@ class Dossier < ActiveRecord::Base
if draft?
submitted!
end
when 'depose'
when 'submit_validate'
if validated?
deposited!
submit_validated!
end
when 'update'
if replied?
@ -93,7 +93,7 @@ class Dossier < ActiveRecord::Base
validated!
end
when 'process'
if deposited?
if submit_validated?
processed!
end
end
@ -102,7 +102,7 @@ class Dossier < ActiveRecord::Base
end
def self.a_traiter
Dossier.where("state='submitted' OR state='updated' OR state='deposited'").order('updated_at ASC')
Dossier.where("state='submitted' OR state='updated' OR state='submit_validated'").order('updated_at ASC')
end
def self.en_attente

View file

@ -39,16 +39,16 @@
%div.row{style: 'text-align:right'}
-unless gestionnaire_signed_in?
-if !@dossier.validated? && !@dossier.deposited? && !@dossier.processed?
-if !@dossier.validated? && !@dossier.submit_validated? && !@dossier.processed?
%a#maj_infos.btn.btn-info{href: "/users/dossiers/#{@dossier.id}/description?back_url=recapitulatif"}
= 'Editer mon dossier'
-unless user_signed_in?
-if !@dossier.validated? && !@dossier.deposited? && !@dossier.processed?
-if !@dossier.validated? && !@dossier.submit_validated? && !@dossier.processed?
= form_tag(url_for({controller: 'backoffice/dossiers', action: :valid, dossier_id: @dossier.id}), class: 'form-inline', method: 'POST') do
%button#action_button.btn.btn-success
= 'Valider le dossier'
-elsif @dossier.deposited?
-elsif @dossier.submit_validated?
= form_tag(url_for({controller: 'backoffice/dossiers', action: :process_end, dossier_id: @dossier.id}), class: 'form-inline', method: 'POST') do
%button#action_button.btn.btn-success
= 'Traiter le dossier'

View file

@ -15,7 +15,7 @@
%button#action_button.btn.btn-success
= 'Soumettre mon dossier'
-elsif @dossier.validated?
= form_tag(url_for({controller: :recapitulatif, action: :depose, dossier_id: @dossier.id}), class: 'form-inline', method: 'POST') do
= form_tag(url_for({controller: :recapitulatif, action: :submit_validate, dossier_id: @dossier.id}), class: 'form-inline', method: 'POST') do
%button#action_button.btn.btn-success
= 'Déposer mon dossier'
-else

View file

@ -27,7 +27,7 @@ Rails.application.routes.draw do
post 'description' => 'description#create'
get '/recapitulatif' => 'recapitulatif#show'
post '/recapitulatif/submit' => 'recapitulatif#submit'
post '/recapitulatif/depose' => 'recapitulatif#depose'
post '/recapitulatif/submit_validate' => 'recapitulatif#submit_validate'
# get '/demande' => 'demandes#show'
# post '/demande' => 'demandes#update'
post '/commentaire' => 'commentaires#create'

View file

@ -0,0 +1,5 @@
class ChangeStateDepositedToSubmitValidate < ActiveRecord::Migration
def change
Dossier.where(state: 'deposited').update_all(state: 'submit_validated')
end
end

View file

@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20151102104309) do
ActiveRecord::Schema.define(version: 20151102105011) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"

View file

@ -48,7 +48,7 @@ describe Backoffice::DossiersController, type: :controller do
describe 'POST #process_end' do
context 'le gestionnaire taite un dossier' do
before do
dossier.deposited!
dossier.submit_validated!
sign_in gestionnaire
end

View file

@ -40,16 +40,16 @@ describe Users::RecapitulatifController, type: :controller do
end
end
describe 'POST #depose' do
describe 'POST #submit_validate' do
context 'when an user depose his dossier' do
before do
dossier.validated!
post :depose, dossier_id: dossier.id
post :submit_validate, dossier_id: dossier.id
end
it 'dossier change his state for deposed' do
it 'dossier change his state for submit_validated' do
dossier.reload
expect(dossier.state).to eq('deposited')
expect(dossier.state).to eq('submit_validated')
end
it 'a message informe user what his dossier is submitted' do

View file

@ -37,8 +37,8 @@ describe DossierDecorator do
expect(subject).to eq('Validé')
end
it 'deposited is dépose' do
dossier.deposited!
it 'submit_validated is dépose' do
dossier.submit_validated!
expect(subject).to eq('Déposé')
end

View file

@ -294,10 +294,10 @@ describe Dossier do
it { is_expected.to eq('validated') }
end
context 'when is deposed the dossier' do
let(:action) { 'depose' }
context 'when is submit_validated the dossier' do
let(:action) { 'submit_validate' }
it { is_expected.to eq('deposited') }
it { is_expected.to eq('submit_validated') }
end
end
@ -312,9 +312,9 @@ describe Dossier do
end
end
context 'when dossier is at state deposited' do
context 'when dossier is at state submit_validated' do
before do
dossier.deposited!
dossier.submit_validated!
end
context 'when user is connect' do
@ -323,7 +323,7 @@ describe Dossier do
context 'when is post a comment' do
let(:action) { 'comment' }
it { is_expected.to eq('deposited') }
it { is_expected.to eq('submit_validated') }
end
end
@ -333,7 +333,7 @@ describe Dossier do
context 'when is post a comment' do
let(:action) { 'comment' }
it {is_expected.to eq('deposited')}
it {is_expected.to eq('submit_validated')}
end
context 'when is processed the dossier' do
@ -378,7 +378,7 @@ describe Dossier do
let!(:dossier4) { create(:dossier, :with_user, :with_procedure, state: 'replied')}
let!(:dossier5) { create(:dossier, :with_user, :with_procedure, state: 'updated')}
let!(:dossier6) { create(:dossier, :with_user, :with_procedure, state: 'validated')}
let!(:dossier7) { create(:dossier, :with_user, :with_procedure, state: 'deposited')}
let!(:dossier7) { create(:dossier, :with_user, :with_procedure, state: 'submit_validated')}
let!(:dossier8) { create(:dossier, :with_user, :with_procedure, state: 'processed')}
describe '#a_traiter' do

View file

@ -103,9 +103,9 @@ describe 'backoffice/dossiers/show.html.haml', type: :view do
end
end
context 'when dossier have state deposited' do
context 'when dossier have state submit_validated' do
before do
dossier.deposited!
dossier.submit_validated!
render
end

View file

@ -100,9 +100,9 @@ describe 'users/recapitulatif/show.html.haml', type: :view do
end
end
context 'when dossier state is deposited' do
context 'when dossier state is submit_validated' do
before do
dossier.deposited!
dossier.submit_validated!
render
end