diff --git a/app/controllers/backoffice/dossiers_controller.rb b/app/controllers/backoffice/dossiers_controller.rb index 4a2e9c29c..2675b1509 100644 --- a/app/controllers/backoffice/dossiers_controller.rb +++ b/app/controllers/backoffice/dossiers_controller.rb @@ -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' diff --git a/app/decorators/dossier_decorator.rb b/app/decorators/dossier_decorator.rb index c13b4dfc3..0f7504bc5 100644 --- a/app/decorators/dossier_decorator.rb +++ b/app/decorators/dossier_decorator.rb @@ -25,7 +25,7 @@ class DossierDecorator < Draper::Decorator 'Validé' when 'submit_validated' 'Déposé' - when 'processed' + when 'closed' 'Traité' else fail 'State not valid' diff --git a/app/models/dossier.rb b/app/models/dossier.rb index 1142aad6f..10fe34ea3 100644 --- a/app/models/dossier.rb +++ b/app/models/dossier.rb @@ -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 diff --git a/app/views/dossiers/_infos_dossier.html.haml b/app/views/dossiers/_infos_dossier.html.haml index b63bc46d2..146e77525 100644 --- a/app/views/dossiers/_infos_dossier.html.haml +++ b/app/views/dossiers/_infos_dossier.html.haml @@ -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' diff --git a/config/routes.rb b/config/routes.rb index 1f4e55ff5..7d69485e8 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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 diff --git a/db/migrate/20151102135824_change_state_processed_to_closed.rb b/db/migrate/20151102135824_change_state_processed_to_closed.rb new file mode 100644 index 000000000..f45f88c4b --- /dev/null +++ b/db/migrate/20151102135824_change_state_processed_to_closed.rb @@ -0,0 +1,5 @@ +class ChangeStateProcessedToClosed < ActiveRecord::Migration + def change + Dossier.where(state: 'processed').update_all(state: 'closed') + end +end diff --git a/db/schema.rb b/db/schema.rb index 9e579f186..2f17d75a5 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -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" diff --git a/spec/controllers/backoffice/dossiers_controller_spec.rb b/spec/controllers/backoffice/dossiers_controller_spec.rb index ade5131c5..a0d22ff3a 100644 --- a/spec/controllers/backoffice/dossiers_controller_spec.rb +++ b/spec/controllers/backoffice/dossiers_controller_spec.rb @@ -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 diff --git a/spec/controllers/users/recapitulatif_controller_spec.rb b/spec/controllers/users/recapitulatif_controller_spec.rb index 095730f72..70318060f 100644 --- a/spec/controllers/users/recapitulatif_controller_spec.rb +++ b/spec/controllers/users/recapitulatif_controller_spec.rb @@ -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 diff --git a/spec/decorators/dossier_decorator_spec.rb b/spec/decorators/dossier_decorator_spec.rb index 7956a5ea5..5df8bb2ec 100644 --- a/spec/decorators/dossier_decorator_spec.rb +++ b/spec/decorators/dossier_decorator_spec.rb @@ -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 diff --git a/spec/models/dossier_spec.rb b/spec/models/dossier_spec.rb index ee7bffa02..1ab2d3453 100644 --- a/spec/models/dossier_spec.rb +++ b/spec/models/dossier_spec.rb @@ -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 } diff --git a/spec/views/backoffice/dossiers/show.html.html_spec.rb b/spec/views/backoffice/dossiers/show.html.html_spec.rb index 5603745a1..45700bf19 100644 --- a/spec/views/backoffice/dossiers/show.html.html_spec.rb +++ b/spec/views/backoffice/dossiers/show.html.html_spec.rb @@ -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 diff --git a/spec/views/users/recapitulatif/show.html.haml_spec.rb b/spec/views/users/recapitulatif/show.html.haml_spec.rb index 0a4907f79..1d0c9b522 100644 --- a/spec/views/users/recapitulatif/show.html.haml_spec.rb +++ b/spec/views/users/recapitulatif/show.html.haml_spec.rb @@ -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é') }