REFACTOR: Change dossier state 'Confirmed' To 'Validated'
This commit is contained in:
parent
4a05af89fc
commit
da8c166331
14 changed files with 50 additions and 44 deletions
|
@ -18,11 +18,11 @@ class Backoffice::DossiersController < ApplicationController
|
|||
redirect_to url_for(controller: '/backoffice')
|
||||
end
|
||||
|
||||
def confirme
|
||||
def valid
|
||||
params[:id] = params[:dossier_id]
|
||||
show
|
||||
|
||||
@dossier.next_step! 'gestionnaire', 'confirme'
|
||||
@dossier.next_step! 'gestionnaire', 'valid'
|
||||
flash.notice = 'Dossier confirmé avec succès.'
|
||||
|
||||
render 'show'
|
||||
|
|
|
@ -21,7 +21,7 @@ class DossierDecorator < Draper::Decorator
|
|||
'Répondu'
|
||||
when 'updated'
|
||||
'Mis à jour'
|
||||
when 'confirmed'
|
||||
when 'validated'
|
||||
'Validé'
|
||||
when 'deposited'
|
||||
'Déposé'
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
class Dossier < ActiveRecord::Base
|
||||
enum state: {draft: 'draft',
|
||||
submitted: 'submitted',
|
||||
replied: 'replied', #replied
|
||||
replied: 'replied',
|
||||
updated: 'updated',
|
||||
confirmed: 'confirmed', #validated
|
||||
deposited: 'deposited', #submit_confirmed
|
||||
validated: 'validated', #-confirmed
|
||||
deposited: 'deposited', #submit_validated
|
||||
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 confirme depose process).include?(action)
|
||||
unless %w(submit replied update comment valid depose process).include?(action)
|
||||
fail 'action is not valid'
|
||||
end
|
||||
|
||||
|
@ -64,7 +64,7 @@ class Dossier < ActiveRecord::Base
|
|||
submitted!
|
||||
end
|
||||
when 'depose'
|
||||
if confirmed?
|
||||
if validated?
|
||||
deposited!
|
||||
end
|
||||
when 'update'
|
||||
|
@ -84,13 +84,13 @@ class Dossier < ActiveRecord::Base
|
|||
elsif submitted?
|
||||
replied!
|
||||
end
|
||||
when 'confirme'
|
||||
when 'valid'
|
||||
if updated?
|
||||
confirmed!
|
||||
validated!
|
||||
elsif replied?
|
||||
confirmed!
|
||||
validated!
|
||||
elsif submitted?
|
||||
confirmed!
|
||||
validated!
|
||||
end
|
||||
when 'process'
|
||||
if deposited?
|
||||
|
@ -106,7 +106,7 @@ class Dossier < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def self.en_attente
|
||||
Dossier.where("state='replied' OR state='confirmed'").order('updated_at ASC')
|
||||
Dossier.where("state='replied' OR state='validated'").order('updated_at ASC')
|
||||
end
|
||||
|
||||
def self.termine
|
||||
|
|
|
@ -39,13 +39,13 @@
|
|||
|
||||
%div.row{style: 'text-align:right'}
|
||||
-unless gestionnaire_signed_in?
|
||||
-if !@dossier.confirmed? && !@dossier.deposited? && !@dossier.processed?
|
||||
-if !@dossier.validated? && !@dossier.deposited? && !@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.confirmed? && !@dossier.deposited? && !@dossier.processed?
|
||||
= form_tag(url_for({controller: 'backoffice/dossiers', action: :confirme, dossier_id: @dossier.id}), class: 'form-inline', method: 'POST') do
|
||||
-if !@dossier.validated? && !@dossier.deposited? && !@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?
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
= form_tag(url_for({controller: :recapitulatif, action: :submit, dossier_id: @dossier.id}), class: 'form-inline', method: 'POST') do
|
||||
%button#action_button.btn.btn-success
|
||||
= 'Soumettre mon dossier'
|
||||
-elsif @dossier.confirmed?
|
||||
-elsif @dossier.validated?
|
||||
= form_tag(url_for({controller: :recapitulatif, action: :depose, dossier_id: @dossier.id}), class: 'form-inline', method: 'POST') do
|
||||
%button#action_button.btn.btn-success
|
||||
= 'Déposer mon dossier'
|
||||
|
|
|
@ -55,7 +55,7 @@ Rails.application.routes.draw do
|
|||
get 'sign_in' => '/gestionnaires/sessions#new'
|
||||
|
||||
resources :dossiers do
|
||||
post 'confirme' => 'dossiers#confirme'
|
||||
post 'valid' => 'dossiers#valid'
|
||||
post 'process' => 'dossiers#process_end'
|
||||
end
|
||||
resources :commentaires, only: [:create]
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
class ChangeStateConfirmedToValidated < ActiveRecord::Migration
|
||||
def change
|
||||
Dossier.where(state: 'confirmed').update_all(state: 'validated')
|
||||
|
||||
end
|
||||
end
|
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20151102102747) do
|
||||
ActiveRecord::Schema.define(version: 20151102104309) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
|
|
@ -29,18 +29,18 @@ describe Backoffice::DossiersController, type: :controller do
|
|||
end
|
||||
end
|
||||
|
||||
describe 'POST #confirme' do
|
||||
describe 'POST #valid' do
|
||||
context 'le gestionnaire valide un dossier' do
|
||||
before do
|
||||
dossier.submitted!
|
||||
sign_in gestionnaire
|
||||
end
|
||||
|
||||
it 'dossier change is state for confirmed' do
|
||||
post :confirme, dossier_id: dossier_id
|
||||
it 'dossier change is state for validated' do
|
||||
post :valid, dossier_id: dossier_id
|
||||
|
||||
dossier.reload
|
||||
expect(dossier.state).to eq('confirmed')
|
||||
expect(dossier.state).to eq('validated')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -43,7 +43,7 @@ describe Users::RecapitulatifController, type: :controller do
|
|||
describe 'POST #depose' do
|
||||
context 'when an user depose his dossier' do
|
||||
before do
|
||||
dossier.confirmed!
|
||||
dossier.validated!
|
||||
post :depose, dossier_id: dossier.id
|
||||
end
|
||||
|
||||
|
|
|
@ -32,8 +32,8 @@ describe DossierDecorator do
|
|||
expect(subject).to eq('Mis à jour')
|
||||
end
|
||||
|
||||
it 'confirmed is valide' do
|
||||
dossier.confirmed!
|
||||
it 'validated is valide' do
|
||||
dossier.validated!
|
||||
expect(subject).to eq('Validé')
|
||||
end
|
||||
|
||||
|
|
|
@ -194,10 +194,10 @@ describe Dossier do
|
|||
it { is_expected.to eq('replied')}
|
||||
end
|
||||
|
||||
context 'when is confirmed the dossier' do
|
||||
let(:action) { 'confirme' }
|
||||
context 'when is validated the dossier' do
|
||||
let(:action) { 'valid' }
|
||||
|
||||
it {is_expected.to eq('confirmed')}
|
||||
it {is_expected.to eq('validated')}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -235,10 +235,10 @@ describe Dossier do
|
|||
it { is_expected.to eq('replied')}
|
||||
end
|
||||
|
||||
context 'when is confirmed the dossier' do
|
||||
let(:action) { 'confirme' }
|
||||
context 'when is validated the dossier' do
|
||||
let(:action) { 'valid' }
|
||||
|
||||
it {is_expected.to eq('confirmed')}
|
||||
it {is_expected.to eq('validated')}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -273,17 +273,17 @@ describe Dossier do
|
|||
it { is_expected.to eq('replied')}
|
||||
end
|
||||
|
||||
context 'when is confirmed the dossier' do
|
||||
let(:action) { 'confirme' }
|
||||
context 'when is validated the dossier' do
|
||||
let(:action) { 'valid' }
|
||||
|
||||
it {is_expected.to eq('confirmed')}
|
||||
it {is_expected.to eq('validated')}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'when dossier is at state confirmed' do
|
||||
context 'when dossier is at state validated' do
|
||||
before do
|
||||
dossier.confirmed!
|
||||
dossier.validated!
|
||||
end
|
||||
|
||||
context 'when user is connect' do
|
||||
|
@ -291,7 +291,7 @@ describe Dossier do
|
|||
|
||||
context 'when is post a comment' do
|
||||
let(:action) { 'comment' }
|
||||
it { is_expected.to eq('confirmed') }
|
||||
it { is_expected.to eq('validated') }
|
||||
end
|
||||
|
||||
context 'when is deposed the dossier' do
|
||||
|
@ -307,7 +307,7 @@ describe Dossier do
|
|||
context 'when is post a comment' do
|
||||
let(:action) { 'comment' }
|
||||
|
||||
it { is_expected.to eq('confirmed')}
|
||||
it { is_expected.to eq('validated')}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -377,7 +377,7 @@ describe Dossier do
|
|||
let!(:dossier3) { create(:dossier, :with_user, :with_procedure, state: 'submitted')}
|
||||
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: 'confirmed')}
|
||||
let!(:dossier6) { create(:dossier, :with_user, :with_procedure, state: 'validated')}
|
||||
let!(:dossier7) { create(:dossier, :with_user, :with_procedure, state: 'deposited')}
|
||||
let!(:dossier8) { create(:dossier, :with_user, :with_procedure, state: 'processed')}
|
||||
|
||||
|
|
|
@ -89,9 +89,9 @@ describe 'backoffice/dossiers/show.html.haml', type: :view do
|
|||
end
|
||||
end
|
||||
|
||||
context 'when dossier have state confirmed' do
|
||||
context 'when dossier have state validated' do
|
||||
before do
|
||||
dossier.confirmed!
|
||||
dossier.validated!
|
||||
render
|
||||
end
|
||||
|
||||
|
|
|
@ -83,9 +83,9 @@ describe 'users/recapitulatif/show.html.haml', type: :view do
|
|||
it { expect(rendered).to have_content('Mis à jour') }
|
||||
end
|
||||
|
||||
context 'when dossier state is confirmed' do
|
||||
context 'when dossier state is validated' do
|
||||
before do
|
||||
dossier.confirmed!
|
||||
dossier.validated!
|
||||
render
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue