REFACTOR: Change dossier state 'Confirmed' To 'Validated'

This commit is contained in:
Xavier J 2015-11-02 11:45:52 +01:00
parent 4a05af89fc
commit da8c166331
14 changed files with 50 additions and 44 deletions

View file

@ -18,11 +18,11 @@ class Backoffice::DossiersController < ApplicationController
redirect_to url_for(controller: '/backoffice') redirect_to url_for(controller: '/backoffice')
end end
def confirme def valid
params[:id] = params[:dossier_id] params[:id] = params[:dossier_id]
show show
@dossier.next_step! 'gestionnaire', 'confirme' @dossier.next_step! 'gestionnaire', 'valid'
flash.notice = 'Dossier confirmé avec succès.' flash.notice = 'Dossier confirmé avec succès.'
render 'show' render 'show'

View file

@ -21,7 +21,7 @@ class DossierDecorator < Draper::Decorator
'Répondu' 'Répondu'
when 'updated' when 'updated'
'Mis à jour' 'Mis à jour'
when 'confirmed' when 'validated'
'Validé' 'Validé'
when 'deposited' when 'deposited'
'Déposé' 'Déposé'

View file

@ -1,10 +1,10 @@
class Dossier < ActiveRecord::Base class Dossier < ActiveRecord::Base
enum state: {draft: 'draft', enum state: {draft: 'draft',
submitted: 'submitted', submitted: 'submitted',
replied: 'replied', #replied replied: 'replied',
updated: 'updated', updated: 'updated',
confirmed: 'confirmed', #validated validated: 'validated', #-confirmed
deposited: 'deposited', #submit_confirmed deposited: 'deposited', #submit_validated
processed: 'processed'} #closed processed: 'processed'} #closed
has_one :etablissement, dependent: :destroy has_one :etablissement, dependent: :destroy
@ -49,7 +49,7 @@ class Dossier < ActiveRecord::Base
end end
def next_step! role, action 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' fail 'action is not valid'
end end
@ -64,7 +64,7 @@ class Dossier < ActiveRecord::Base
submitted! submitted!
end end
when 'depose' when 'depose'
if confirmed? if validated?
deposited! deposited!
end end
when 'update' when 'update'
@ -84,13 +84,13 @@ class Dossier < ActiveRecord::Base
elsif submitted? elsif submitted?
replied! replied!
end end
when 'confirme' when 'valid'
if updated? if updated?
confirmed! validated!
elsif replied? elsif replied?
confirmed! validated!
elsif submitted? elsif submitted?
confirmed! validated!
end end
when 'process' when 'process'
if deposited? if deposited?
@ -106,7 +106,7 @@ class Dossier < ActiveRecord::Base
end end
def self.en_attente 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 end
def self.termine def self.termine

View file

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

View file

@ -14,7 +14,7 @@
= form_tag(url_for({controller: :recapitulatif, action: :submit, dossier_id: @dossier.id}), class: 'form-inline', method: 'POST') do = form_tag(url_for({controller: :recapitulatif, action: :submit, dossier_id: @dossier.id}), class: 'form-inline', method: 'POST') do
%button#action_button.btn.btn-success %button#action_button.btn.btn-success
= 'Soumettre mon dossier' = '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 = form_tag(url_for({controller: :recapitulatif, action: :depose, dossier_id: @dossier.id}), class: 'form-inline', method: 'POST') do
%button#action_button.btn.btn-success %button#action_button.btn.btn-success
= 'Déposer mon dossier' = 'Déposer mon dossier'

View file

@ -55,7 +55,7 @@ Rails.application.routes.draw do
get 'sign_in' => '/gestionnaires/sessions#new' get 'sign_in' => '/gestionnaires/sessions#new'
resources :dossiers do resources :dossiers do
post 'confirme' => 'dossiers#confirme' post 'valid' => 'dossiers#valid'
post 'process' => 'dossiers#process_end' post 'process' => 'dossiers#process_end'
end end
resources :commentaires, only: [:create] resources :commentaires, only: [:create]

View file

@ -0,0 +1,6 @@
class ChangeStateConfirmedToValidated < ActiveRecord::Migration
def change
Dossier.where(state: 'confirmed').update_all(state: 'validated')
end
end

View file

@ -11,7 +11,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # 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 # These are extensions that must be enabled in order to support this database
enable_extension "plpgsql" enable_extension "plpgsql"

View file

@ -29,18 +29,18 @@ describe Backoffice::DossiersController, type: :controller do
end end
end end
describe 'POST #confirme' do describe 'POST #valid' do
context 'le gestionnaire valide un dossier' do context 'le gestionnaire valide un dossier' do
before do before do
dossier.submitted! dossier.submitted!
sign_in gestionnaire sign_in gestionnaire
end end
it 'dossier change is state for confirmed' do it 'dossier change is state for validated' do
post :confirme, dossier_id: dossier_id post :valid, dossier_id: dossier_id
dossier.reload dossier.reload
expect(dossier.state).to eq('confirmed') expect(dossier.state).to eq('validated')
end end
end end
end end

View file

@ -43,7 +43,7 @@ describe Users::RecapitulatifController, type: :controller do
describe 'POST #depose' do describe 'POST #depose' do
context 'when an user depose his dossier' do context 'when an user depose his dossier' do
before do before do
dossier.confirmed! dossier.validated!
post :depose, dossier_id: dossier.id post :depose, dossier_id: dossier.id
end end

View file

@ -32,8 +32,8 @@ describe DossierDecorator do
expect(subject).to eq('Mis à jour') expect(subject).to eq('Mis à jour')
end end
it 'confirmed is valide' do it 'validated is valide' do
dossier.confirmed! dossier.validated!
expect(subject).to eq('Validé') expect(subject).to eq('Validé')
end end

View file

@ -194,10 +194,10 @@ describe Dossier do
it { is_expected.to eq('replied')} it { is_expected.to eq('replied')}
end end
context 'when is confirmed the dossier' do context 'when is validated the dossier' do
let(:action) { 'confirme' } let(:action) { 'valid' }
it {is_expected.to eq('confirmed')} it {is_expected.to eq('validated')}
end end
end end
end end
@ -235,10 +235,10 @@ describe Dossier do
it { is_expected.to eq('replied')} it { is_expected.to eq('replied')}
end end
context 'when is confirmed the dossier' do context 'when is validated the dossier' do
let(:action) { 'confirme' } let(:action) { 'valid' }
it {is_expected.to eq('confirmed')} it {is_expected.to eq('validated')}
end end
end end
end end
@ -273,17 +273,17 @@ describe Dossier do
it { is_expected.to eq('replied')} it { is_expected.to eq('replied')}
end end
context 'when is confirmed the dossier' do context 'when is validated the dossier' do
let(:action) { 'confirme' } let(:action) { 'valid' }
it {is_expected.to eq('confirmed')} it {is_expected.to eq('validated')}
end end
end end
end end
context 'when dossier is at state confirmed' do context 'when dossier is at state validated' do
before do before do
dossier.confirmed! dossier.validated!
end end
context 'when user is connect' do context 'when user is connect' do
@ -291,7 +291,7 @@ describe Dossier do
context 'when is post a comment' do context 'when is post a comment' do
let(:action) { 'comment' } let(:action) { 'comment' }
it { is_expected.to eq('confirmed') } it { is_expected.to eq('validated') }
end end
context 'when is deposed the dossier' do context 'when is deposed the dossier' do
@ -307,7 +307,7 @@ describe Dossier do
context 'when is post a comment' do context 'when is post a comment' do
let(:action) { 'comment' } let(:action) { 'comment' }
it { is_expected.to eq('confirmed')} it { is_expected.to eq('validated')}
end end
end end
end end
@ -377,7 +377,7 @@ describe Dossier do
let!(:dossier3) { create(:dossier, :with_user, :with_procedure, state: 'submitted')} let!(:dossier3) { create(:dossier, :with_user, :with_procedure, state: 'submitted')}
let!(:dossier4) { create(:dossier, :with_user, :with_procedure, state: 'replied')} let!(:dossier4) { create(:dossier, :with_user, :with_procedure, state: 'replied')}
let!(:dossier5) { create(:dossier, :with_user, :with_procedure, state: 'updated')} 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!(:dossier7) { create(:dossier, :with_user, :with_procedure, state: 'deposited')}
let!(:dossier8) { create(:dossier, :with_user, :with_procedure, state: 'processed')} let!(:dossier8) { create(:dossier, :with_user, :with_procedure, state: 'processed')}

View file

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

View file

@ -83,9 +83,9 @@ describe 'users/recapitulatif/show.html.haml', type: :view do
it { expect(rendered).to have_content('Mis à jour') } it { expect(rendered).to have_content('Mis à jour') }
end end
context 'when dossier state is confirmed' do context 'when dossier state is validated' do
before do before do
dossier.confirmed! dossier.validated!
render render
end end