REFACTOR: Change dossier state 'Processed' To 'Closed'
This commit is contained in:
parent
76d87c7f79
commit
c09fe8e7f6
13 changed files with 37 additions and 32 deletions
|
@ -28,12 +28,12 @@ class Backoffice::DossiersController < ApplicationController
|
|||
render 'show'
|
||||
end
|
||||
|
||||
def process_end
|
||||
def close
|
||||
params[:id] = params[:dossier_id]
|
||||
|
||||
show
|
||||
|
||||
@dossier.next_step! 'gestionnaire', 'process'
|
||||
@dossier.next_step! 'gestionnaire', 'close'
|
||||
flash.notice = 'Dossier traité avec succès.'
|
||||
|
||||
render 'show'
|
||||
|
|
|
@ -25,7 +25,7 @@ class DossierDecorator < Draper::Decorator
|
|||
'Validé'
|
||||
when 'submit_validated'
|
||||
'Déposé'
|
||||
when 'processed'
|
||||
when 'closed'
|
||||
'Traité'
|
||||
else
|
||||
fail 'State not valid'
|
||||
|
|
|
@ -4,8 +4,8 @@ class Dossier < ActiveRecord::Base
|
|||
replied: 'replied',
|
||||
updated: 'updated',
|
||||
validated: 'validated',
|
||||
submit_validated: 'submit_validated', #deposited
|
||||
processed: 'processed'} #closed
|
||||
submit_validated: 'submit_validated',
|
||||
closed: 'closed'} #-processed
|
||||
|
||||
has_one :etablissement, dependent: :destroy
|
||||
has_one :entreprise, dependent: :destroy
|
||||
|
@ -49,7 +49,7 @@ class Dossier < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def next_step! role, action
|
||||
unless %w(submit replied update comment valid submit_validate process).include?(action)
|
||||
unless %w(submit replied update comment valid submit_validate close).include?(action)
|
||||
fail 'action is not valid'
|
||||
end
|
||||
|
||||
|
@ -92,9 +92,9 @@ class Dossier < ActiveRecord::Base
|
|||
elsif submitted?
|
||||
validated!
|
||||
end
|
||||
when 'process'
|
||||
when 'close'
|
||||
if submit_validated?
|
||||
processed!
|
||||
closed!
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -110,7 +110,7 @@ class Dossier < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def self.termine
|
||||
Dossier.where("state='processed'").order('updated_at ASC')
|
||||
Dossier.where("state='closed'").order('updated_at ASC')
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -39,17 +39,17 @@
|
|||
|
||||
%div.row{style: 'text-align:right'}
|
||||
-unless gestionnaire_signed_in?
|
||||
-if !@dossier.validated? && !@dossier.submit_validated? && !@dossier.processed?
|
||||
-if !@dossier.validated? && !@dossier.submit_validated? && !@dossier.closed?
|
||||
%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.submit_validated? && !@dossier.processed?
|
||||
-if !@dossier.validated? && !@dossier.submit_validated? && !@dossier.closed?
|
||||
= 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.submit_validated?
|
||||
= form_tag(url_for({controller: 'backoffice/dossiers', action: :process_end, dossier_id: @dossier.id}), class: 'form-inline', method: 'POST') do
|
||||
= form_tag(url_for({controller: 'backoffice/dossiers', action: :close, dossier_id: @dossier.id}), class: 'form-inline', method: 'POST') do
|
||||
%button#action_button.btn.btn-success
|
||||
= 'Traiter le dossier'
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ Rails.application.routes.draw do
|
|||
|
||||
resources :dossiers do
|
||||
post 'valid' => 'dossiers#valid'
|
||||
post 'process' => 'dossiers#process_end'
|
||||
post 'close' => 'dossiers#close'
|
||||
end
|
||||
resources :commentaires, only: [:create]
|
||||
end
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
class ChangeStateProcessedToClosed < ActiveRecord::Migration
|
||||
def change
|
||||
Dossier.where(state: 'processed').update_all(state: 'closed')
|
||||
end
|
||||
end
|
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20151102105011) do
|
||||
ActiveRecord::Schema.define(version: 20151102135824) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
|
|
@ -45,18 +45,18 @@ describe Backoffice::DossiersController, type: :controller do
|
|||
end
|
||||
end
|
||||
|
||||
describe 'POST #process_end' do
|
||||
describe 'POST #close' do
|
||||
context 'le gestionnaire taite un dossier' do
|
||||
before do
|
||||
dossier.submit_validated!
|
||||
sign_in gestionnaire
|
||||
end
|
||||
|
||||
it 'dossier change is state for processed' do
|
||||
post :process_end, dossier_id: dossier_id
|
||||
it 'dossier change is state for closed' do
|
||||
post :close, dossier_id: dossier_id
|
||||
|
||||
dossier.reload
|
||||
expect(dossier.state).to eq('processed')
|
||||
expect(dossier.state).to eq('closed')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -29,7 +29,7 @@ describe Users::RecapitulatifController, type: :controller do
|
|||
post :submit, dossier_id: dossier.id
|
||||
end
|
||||
|
||||
it 'dossier change his state for processed' do
|
||||
it 'dossier change his state for closed' do
|
||||
dossier.reload
|
||||
expect(dossier.state).to eq('submitted')
|
||||
end
|
||||
|
|
|
@ -42,8 +42,8 @@ describe DossierDecorator do
|
|||
expect(subject).to eq('Déposé')
|
||||
end
|
||||
|
||||
it 'processed is traité' do
|
||||
dossier.processed!
|
||||
it 'closed is traité' do
|
||||
dossier.closed!
|
||||
expect(subject).to eq('Traité')
|
||||
end
|
||||
end
|
||||
|
|
|
@ -336,17 +336,17 @@ describe Dossier do
|
|||
it {is_expected.to eq('submit_validated')}
|
||||
end
|
||||
|
||||
context 'when is processed the dossier' do
|
||||
let(:action) { 'process' }
|
||||
context 'when is closed the dossier' do
|
||||
let(:action) { 'close' }
|
||||
|
||||
it {is_expected.to eq('processed')}
|
||||
it {is_expected.to eq('closed')}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'when dossier is at state processed' do
|
||||
context 'when dossier is at state closed' do
|
||||
before do
|
||||
dossier.processed!
|
||||
dossier.closed!
|
||||
end
|
||||
|
||||
context 'when user is connect' do
|
||||
|
@ -355,7 +355,7 @@ describe Dossier do
|
|||
context 'when is post a comment' do
|
||||
let(:action) { 'comment' }
|
||||
|
||||
it { is_expected.to eq('processed')}
|
||||
it { is_expected.to eq('closed')}
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -365,7 +365,7 @@ describe Dossier do
|
|||
context 'when is post a comment' do
|
||||
let(:action) { 'comment' }
|
||||
|
||||
it { is_expected.to eq('processed')}
|
||||
it { is_expected.to eq('closed')}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -379,7 +379,7 @@ describe Dossier do
|
|||
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: 'submit_validated')}
|
||||
let!(:dossier8) { create(:dossier, :with_user, :with_procedure, state: 'processed')}
|
||||
let!(:dossier8) { create(:dossier, :with_user, :with_procedure, state: 'closed')}
|
||||
|
||||
describe '#a_traiter' do
|
||||
subject { described_class.a_traiter }
|
||||
|
|
|
@ -121,9 +121,9 @@ describe 'backoffice/dossiers/show.html.haml', type: :view do
|
|||
end
|
||||
end
|
||||
|
||||
context 'when dossier have state processed' do
|
||||
context 'when dossier have state closed' do
|
||||
before do
|
||||
dossier.processed!
|
||||
dossier.closed!
|
||||
render
|
||||
end
|
||||
|
||||
|
|
|
@ -116,7 +116,7 @@ describe 'users/recapitulatif/show.html.haml', type: :view do
|
|||
|
||||
context 'when dossier state is traité' do
|
||||
before do
|
||||
dossier.processed!
|
||||
dossier.closed!
|
||||
render
|
||||
end
|
||||
it { expect(rendered).to have_content('Traité') }
|
||||
|
|
Loading…
Reference in a new issue