diff --git a/app/controllers/users/description_controller.rb b/app/controllers/users/description_controller.rb index 7f95d1394..3338f33a9 100644 --- a/app/controllers/users/description_controller.rb +++ b/app/controllers/users/description_controller.rb @@ -45,7 +45,7 @@ class Users::DescriptionController < UsersController commentaire.dossier = @dossier commentaire.save else - @dossier.submitted! + @dossier.initiated! end flash.notice = 'Félicitation, votre demande a bien été enregistrée.' diff --git a/app/controllers/users/recapitulatif_controller.rb b/app/controllers/users/recapitulatif_controller.rb index aeec34139..e62edcdff 100644 --- a/app/controllers/users/recapitulatif_controller.rb +++ b/app/controllers/users/recapitulatif_controller.rb @@ -16,10 +16,10 @@ class Users::RecapitulatifController < UsersController redirect_to url_for(root_path) end - def submit + def initiate show - @dossier.next_step! 'user', 'submit' + @dossier.next_step! 'user', 'initiate' flash.notice = 'Dossier soumis avec succès.' render 'show' diff --git a/app/decorators/dossier_decorator.rb b/app/decorators/dossier_decorator.rb index 0f7504bc5..444ad467e 100644 --- a/app/decorators/dossier_decorator.rb +++ b/app/decorators/dossier_decorator.rb @@ -15,7 +15,7 @@ class DossierDecorator < Draper::Decorator case state when 'draft' 'Brouillon' - when 'submitted' + when 'initiated' 'Soumis' when 'replied' 'Répondu' diff --git a/app/models/dossier.rb b/app/models/dossier.rb index 10fe34ea3..71c84ef72 100644 --- a/app/models/dossier.rb +++ b/app/models/dossier.rb @@ -1,10 +1,10 @@ class Dossier < ActiveRecord::Base enum state: {draft: 'draft', - submitted: 'submitted', + initiated: 'initiated', #-submitted replied: 'replied', updated: 'updated', validated: 'validated', - submit_validated: 'submit_validated', + submit_validated: 'submit_validated', #initiated closed: 'closed'} #-processed 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 submit_validate close).include?(action) + unless %w(initiate replied update comment valid submit_validate close).include?(action) fail 'action is not valid' end @@ -59,9 +59,9 @@ class Dossier < ActiveRecord::Base if role == 'user' case action - when 'submit' + when 'initiate' if draft? - submitted! + initiated! end when 'submit_validate' if validated? @@ -81,7 +81,7 @@ class Dossier < ActiveRecord::Base when 'comment' if updated? replied! - elsif submitted? + elsif initiated? replied! end when 'valid' @@ -89,7 +89,7 @@ class Dossier < ActiveRecord::Base validated! elsif replied? validated! - elsif submitted? + elsif initiated? validated! end when 'close' @@ -102,7 +102,7 @@ class Dossier < ActiveRecord::Base end def self.a_traiter - Dossier.where("state='submitted' OR state='updated' OR state='submit_validated'").order('updated_at ASC') + Dossier.where("state='initiated' OR state='updated' OR state='submit_validated'").order('updated_at ASC') end def self.en_attente diff --git a/app/views/users/recapitulatif/show.html.haml b/app/views/users/recapitulatif/show.html.haml index 9f3997aba..cdc1dd7a7 100644 --- a/app/views/users/recapitulatif/show.html.haml +++ b/app/views/users/recapitulatif/show.html.haml @@ -11,7 +11,7 @@ - unless gestionnaire_signed_in? -if @dossier.draft? - = 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: :initiate, dossier_id: @dossier.id}), class: 'form-inline', method: 'POST') do %button#action_button.btn.btn-success = 'Soumettre mon dossier' -elsif @dossier.validated? diff --git a/config/routes.rb b/config/routes.rb index 7d69485e8..5f7230427 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -26,7 +26,7 @@ Rails.application.routes.draw do get '/description/error' => 'description#error' post 'description' => 'description#create' get '/recapitulatif' => 'recapitulatif#show' - post '/recapitulatif/submit' => 'recapitulatif#submit' + post '/recapitulatif/initiate' => 'recapitulatif#initiate' post '/recapitulatif/submit_validate' => 'recapitulatif#submit_validate' # get '/demande' => 'demandes#show' # post '/demande' => 'demandes#update' diff --git a/db/migrate/20151102142940_change_state_submitted_to_initiated.rb b/db/migrate/20151102142940_change_state_submitted_to_initiated.rb new file mode 100644 index 000000000..cbce3e7d0 --- /dev/null +++ b/db/migrate/20151102142940_change_state_submitted_to_initiated.rb @@ -0,0 +1,5 @@ +class ChangeStateSubmittedToInitiated < ActiveRecord::Migration + def change + Dossier.where(state: 'submitted').update_all(state: 'initiated') + end +end diff --git a/db/schema.rb b/db/schema.rb index 2f17d75a5..f26ad196e 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: 20151102135824) do +ActiveRecord::Schema.define(version: 20151102142940) 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 a0d22ff3a..e4d437bc9 100644 --- a/spec/controllers/backoffice/dossiers_controller_spec.rb +++ b/spec/controllers/backoffice/dossiers_controller_spec.rb @@ -32,7 +32,7 @@ describe Backoffice::DossiersController, type: :controller do describe 'POST #valid' do context 'le gestionnaire valide un dossier' do before do - dossier.submitted! + dossier.initiated! sign_in gestionnaire end diff --git a/spec/controllers/users/carte_controller_spec.rb b/spec/controllers/users/carte_controller_spec.rb index c7806434b..203be7681 100644 --- a/spec/controllers/users/carte_controller_spec.rb +++ b/spec/controllers/users/carte_controller_spec.rb @@ -49,7 +49,7 @@ RSpec.describe Users::CarteController, type: :controller do end context 'En train de modifier la localisation' do - let(:dossier) { create(:dossier, :with_procedure, :with_user, ref_dossier_carto: ref_dossier_carto, state: 'submitted') } + let(:dossier) { create(:dossier, :with_procedure, :with_user, ref_dossier_carto: ref_dossier_carto, state: 'initiated') } before do post :save_ref_api_carto, dossier_id: dossier_id, ref_dossier_carto: ref_dossier_carto end diff --git a/spec/controllers/users/description_controller_spec.rb b/spec/controllers/users/description_controller_spec.rb index fcd9be29a..6c01573ee 100644 --- a/spec/controllers/users/description_controller_spec.rb +++ b/spec/controllers/users/description_controller_spec.rb @@ -65,14 +65,14 @@ describe Users::DescriptionController, type: :controller do end it 'etat du dossier est soumis' do - expect(dossier.state).to eq('submitted') + expect(dossier.state).to eq('initiated') end end # TODO changer les valeurs des champs et check in bdd context 'En train de manipuler un dossier non brouillon' do before do - dossier.submitted! + dossier.initiated! post :create, dossier_id: dossier_id, nom_projet: nom_projet, description: description, montant_projet: montant_projet, montant_aide_demande: montant_aide_demande, date_previsionnelle: date_previsionnelle dossier.reload end diff --git a/spec/controllers/users/recapitulatif_controller_spec.rb b/spec/controllers/users/recapitulatif_controller_spec.rb index 70318060f..8725cf8ff 100644 --- a/spec/controllers/users/recapitulatif_controller_spec.rb +++ b/spec/controllers/users/recapitulatif_controller_spec.rb @@ -23,18 +23,18 @@ describe Users::RecapitulatifController, type: :controller do end - describe 'POST #submit' do - context 'when an user submit his dossier' do + describe 'POST #initiate' do + context 'when an user initiate his dossier' do before do - post :submit, dossier_id: dossier.id + post :initiate, dossier_id: dossier.id end it 'dossier change his state for closed' do dossier.reload - expect(dossier.state).to eq('submitted') + expect(dossier.state).to eq('initiated') end - it 'a message informe user what his dossier is submitted' do + it 'a message informe user what his dossier is initiated' do expect(flash[:notice]).to include('Dossier soumis avec succès.') end end @@ -52,7 +52,7 @@ describe Users::RecapitulatifController, type: :controller do expect(dossier.state).to eq('submit_validated') end - it 'a message informe user what his dossier is submitted' do + it 'a message informe user what his dossier is initiated' do expect(flash[:notice]).to include('Dossier déposé avec succès.') end end diff --git a/spec/decorators/dossier_decorator_spec.rb b/spec/decorators/dossier_decorator_spec.rb index 5df8bb2ec..ea64b1e8f 100644 --- a/spec/decorators/dossier_decorator_spec.rb +++ b/spec/decorators/dossier_decorator_spec.rb @@ -17,8 +17,8 @@ describe DossierDecorator do expect(subject).to eq('Brouillon') end - it 'submitted is submit' do - dossier.submitted! + it 'initiated is initiate' do + dossier.initiated! expect(subject).to eq('Soumis') end diff --git a/spec/models/dossier_spec.rb b/spec/models/dossier_spec.rb index 1ab2d3453..ff3632889 100644 --- a/spec/models/dossier_spec.rb +++ b/spec/models/dossier_spec.rb @@ -122,7 +122,7 @@ describe Dossier do describe '#next_step' do let(:dossier) { create(:dossier, :with_user) } let(:role) { 'user' } - let(:action) { 'submit' } + let(:action) { 'initiate' } subject { dossier.next_step! role, action } @@ -156,17 +156,17 @@ describe Dossier do it { is_expected.to eq('draft') } end - context 'when he submit a dossier' do - let(:action) { 'submit' } + context 'when he initiate a dossier' do + let(:action) { 'initiate' } - it { is_expected.to eq('submitted') } + it { is_expected.to eq('initiated') } end end end - context 'when dossier is at state submitted' do + context 'when dossier is at state initiated' do before do - dossier.submitted! + dossier.initiated! end context 'when user is connect' do @@ -175,13 +175,13 @@ describe Dossier do context 'when is update dossier informations' do let(:action) { 'update' } - it {is_expected.to eq('submitted')} + it {is_expected.to eq('initiated')} end context 'when is post a comment' do let(:action) { 'comment' } - it {is_expected.to eq('submitted')} + it {is_expected.to eq('initiated')} end end @@ -373,8 +373,8 @@ describe Dossier do context 'gestionnaire backoffice methods' do let!(:dossier1) { create(:dossier, :with_user, :with_procedure, state: 'draft')} - let!(:dossier2) { create(:dossier, :with_user, :with_procedure, state: 'submitted')} - let!(:dossier3) { create(:dossier, :with_user, :with_procedure, state: 'submitted')} + let!(:dossier2) { create(:dossier, :with_user, :with_procedure, state: 'initiated')} + let!(:dossier3) { create(:dossier, :with_user, :with_procedure, state: 'initiated')} 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')} diff --git a/spec/views/backoffice/dossiers/show.html.html_spec.rb b/spec/views/backoffice/dossiers/show.html.html_spec.rb index 45700bf19..1d82a8935 100644 --- a/spec/views/backoffice/dossiers/show.html.html_spec.rb +++ b/spec/views/backoffice/dossiers/show.html.html_spec.rb @@ -47,9 +47,9 @@ describe 'backoffice/dossiers/show.html.haml', type: :view do end context 'gestion des etats du dossier' do - context 'when dossier have state submitted' do + context 'when dossier have state initiated' do before do - dossier.submitted! + dossier.initiated! render end diff --git a/spec/views/backoffice/index.html.haml_spec.rb b/spec/views/backoffice/index.html.haml_spec.rb index 412674cdc..784a42038 100644 --- a/spec/views/backoffice/index.html.haml_spec.rb +++ b/spec/views/backoffice/index.html.haml_spec.rb @@ -8,7 +8,7 @@ describe 'backoffice/index.html.haml', type: :view do assign(:dossiers_en_attente, Dossier.en_attente.decorate) assign(:dossiers_termine, Dossier.termine.decorate) - decorate_dossier.submitted! + decorate_dossier.initiated! render end subject { rendered } diff --git a/spec/views/users/carte/show.html.haml_spec.rb b/spec/views/users/carte/show.html.haml_spec.rb index 8b0403386..7d10bc568 100644 --- a/spec/views/users/carte/show.html.haml_spec.rb +++ b/spec/views/users/carte/show.html.haml_spec.rb @@ -46,7 +46,7 @@ describe 'users/carte/show.html.haml', type: :view do end context 'si la page précédente est recapitularif' do - let(:state) { 'submitted' } + let(:state) { 'initiated' } it 'le bouton "Etape suivante" n\'est pas présent' do expect(rendered).to_not have_selector('#etape_suivante') diff --git a/spec/views/users/description/show.html.haml_spec.rb b/spec/views/users/description/show.html.haml_spec.rb index 53e3c5491..aa70bc996 100644 --- a/spec/views/users/description/show.html.haml_spec.rb +++ b/spec/views/users/description/show.html.haml_spec.rb @@ -70,7 +70,7 @@ describe 'users/description/show.html.haml', type: :view do context 'si la page précédente est recapitularif' do before do - dossier.submitted! + dossier.initiated! dossier.reload 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 1d0c9b522..eed79603a 100644 --- a/spec/views/users/recapitulatif/show.html.haml_spec.rb +++ b/spec/views/users/recapitulatif/show.html.haml_spec.rb @@ -55,9 +55,9 @@ describe 'users/recapitulatif/show.html.haml', type: :view do end end - context 'when dossier state is submitted' do + context 'when dossier state is initiated' do before do - dossier.submitted! + dossier.initiated! render end