From 72bae2c374309699f2ac49ea3777a820edd5d0aa Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Mon, 4 Dec 2017 16:17:15 +0100 Subject: [PATCH] [fix #504] Dossier: draft -> brouillon --- app/controllers/stats_controller.rb | 2 +- app/controllers/users/carte_controller.rb | 4 ++-- .../users/description_controller.rb | 10 ++++----- app/controllers/users/dossiers_controller.rb | 4 ++-- app/models/cerfa.rb | 2 +- app/models/champ.rb | 2 +- app/models/dossier.rb | 8 +++---- app/models/piece_justificative.rb | 2 +- app/views/dossiers/_dossier_show.html.haml | 2 +- app/views/root/landing.html.haml | 2 +- app/views/users/carte/show.html.haml | 2 +- app/views/users/description/_show.html.haml | 2 +- config/locales/models/dossier/fr.yml | 2 +- ..._04_translate_dossier_state_to_french.rake | 4 ++++ .../procedures_controller_spec.rb | 8 +++---- spec/controllers/stats_controller_spec.rb | 4 ++-- .../description_controller_shared_example.rb | 14 ++++++------ .../users/dossiers_controller_spec.rb | 16 +++++++------- .../users/recapitulatif_controller_spec.rb | 4 ++-- spec/decorators/dossier_decorator_spec.rb | 6 ++--- .../admin_procedures_show_facades_spec.rb | 2 +- spec/factories/dossier.rb | 2 +- spec/jobs/auto_archive_procedure_job_spec.rb | 4 ++-- ...receive_dossiers_for_procedure_job_spec.rb | 8 +++---- spec/models/dossier_spec.rb | 22 +++++++++---------- spec/models/procedure_overview_spec.rb | 4 ++-- spec/models/procedure_spec.rb | 6 ++--- spec/models/search_spec.rb | 4 ++-- ...dossiers_list_gestionnaire_service_spec.rb | 2 +- .../user_routes_authorization_service_spec.rb | 20 ++++++++--------- ...backoffice_dossierscontroller_show_spec.rb | 2 +- ...users_recapitulatifcontroller_show_spec.rb | 2 +- spec/views/users/carte/show.html.haml_spec.rb | 2 +- .../recapitulatif/show.html.haml_spec.rb | 2 +- 34 files changed, 93 insertions(+), 89 deletions(-) diff --git a/app/controllers/stats_controller.rb b/app/controllers/stats_controller.rb index 5936fcdcf..b62d12505 100644 --- a/app/controllers/stats_controller.rb +++ b/app/controllers/stats_controller.rb @@ -5,7 +5,7 @@ class StatsController < ApplicationController def index procedures = Procedure.publiees_ou_archivees - dossiers = Dossier.where.not(:state => :draft) + dossiers = Dossier.where.not(:state => :brouillon) @procedures_count = procedures.count @dossiers_count = dossiers.count diff --git a/app/controllers/users/carte_controller.rb b/app/controllers/users/carte_controller.rb index d296d5665..ae55a41c6 100644 --- a/app/controllers/users/carte_controller.rb +++ b/app/controllers/users/carte_controller.rb @@ -25,7 +25,7 @@ class Users::CarteController < UsersController dossier.update_attributes(json_latlngs: params[:json_latlngs]) controller = :recapitulatif - controller = :description if dossier.draft? + controller = :description if dossier.brouillon? redirect_to url_for(controller: controller, action: :show, dossier_id: params[:dossier_id]) end @@ -61,7 +61,7 @@ class Users::CarteController < UsersController def self.route_authorization { - states: [:draft, :en_construction], + states: [:brouillon, :en_construction], api_carto: true } end diff --git a/app/controllers/users/description_controller.rb b/app/controllers/users/description_controller.rb index 0fc4489c9..70c95f5fd 100644 --- a/app/controllers/users/description_controller.rb +++ b/app/controllers/users/description_controller.rb @@ -39,18 +39,18 @@ class Users::DescriptionController < UsersController errors_upload = PiecesJustificativesService.upload!(dossier, current_user, params) return redirect_to_description_with_errors(dossier, errors_upload) if errors_upload.any? - if params[:champs] && !draft_submission? + if params[:champs] && !brouillon_submission? errors = ChampsService.build_error_messages(dossier.champs) + PiecesJustificativesService.missing_pj_error_messages(dossier) return redirect_to_description_with_errors(dossier, errors) if errors.any? end - if draft_submission? + if brouillon_submission? flash.notice = 'Votre brouillon a bien été sauvegardé.' redirect_to url_for(controller: :dossiers, action: :index, liste: :brouillon) else - if dossier.draft? + if dossier.brouillon? NotificationMailer.send_notification(dossier, procedure.initiated_mail_template).deliver_now! dossier.en_construction! end @@ -93,7 +93,7 @@ class Users::DescriptionController < UsersController def self.route_authorization { - states: [:draft, :en_construction] + states: [:brouillon, :en_construction] } end @@ -110,7 +110,7 @@ class Users::DescriptionController < UsersController redirect_to users_dossier_description_path(dossier_id: dossier.id) end - def draft_submission? + def brouillon_submission? params[:submit] && params[:submit].keys.first == 'brouillon' end diff --git a/app/controllers/users/dossiers_controller.rb b/app/controllers/users/dossiers_controller.rb index a2bed1390..1d6473262 100644 --- a/app/controllers/users/dossiers_controller.rb +++ b/app/controllers/users/dossiers_controller.rb @@ -62,7 +62,7 @@ class Users::DossiersController < UsersController def new procedure = Procedure.publiees.find(params[:procedure_id]) - dossier = Dossier.create(procedure: procedure, user: current_user, state: 'draft') + dossier = Dossier.create(procedure: procedure, user: current_user, state: 'brouillon') siret = params[:siret] || current_user.siret update_current_user_siret! siret unless siret.nil? @@ -151,7 +151,7 @@ class Users::DossiersController < UsersController def self.route_authorization { - states: [:draft] + states: [:brouillon] } end diff --git a/app/models/cerfa.rb b/app/models/cerfa.rb index 556d69af9..475344c28 100644 --- a/app/models/cerfa.rb +++ b/app/models/cerfa.rb @@ -24,7 +24,7 @@ class Cerfa < ActiveRecord::Base private def internal_notification - unless dossier.state == 'draft' + unless dossier.state == 'brouillon' NotificationService.new('cerfa', self.dossier.id).notify end end diff --git a/app/models/champ.rb b/app/models/champ.rb index 9f8b8d75f..5eb554853 100644 --- a/app/models/champ.rb +++ b/app/models/champ.rb @@ -117,7 +117,7 @@ class Champ < ActiveRecord::Base end def internal_notification - if dossier.state != 'draft' + if dossier.state != 'brouillon' if type == 'ChampPublic' NotificationService.new('champs', self.dossier.id, self.libelle).notify else diff --git a/app/models/dossier.rb b/app/models/dossier.rb index 38848b077..510146be5 100644 --- a/app/models/dossier.rb +++ b/app/models/dossier.rb @@ -1,6 +1,6 @@ class Dossier < ActiveRecord::Base enum state: { - draft: 'draft', + brouillon: 'brouillon', en_construction: 'en_construction', received: 'received', closed: 'closed', @@ -8,7 +8,7 @@ class Dossier < ActiveRecord::Base without_continuation: 'without_continuation' } - BROUILLON = %w(draft) + BROUILLON = %w(brouillon) NOUVEAUX = %w(en_construction) EN_CONSTRUCTION = %w(en_construction) EN_INSTRUCTION = %w(received) @@ -157,7 +157,7 @@ class Dossier < ActiveRecord::Base when 'user' case action when 'initiate' - if draft? + if brouillon? en_construction! end end @@ -295,7 +295,7 @@ class Dossier < ActiveRecord::Base end def can_be_en_construction? - !(procedure.archivee? && draft?) + !(procedure.archivee? && brouillon?) end def text_summary diff --git a/app/models/piece_justificative.rb b/app/models/piece_justificative.rb index 393d892cc..25c83e7bd 100644 --- a/app/models/piece_justificative.rb +++ b/app/models/piece_justificative.rb @@ -59,7 +59,7 @@ class PieceJustificative < ActiveRecord::Base private def internal_notification - unless self.type_de_piece_justificative.nil? && dossier.state == 'draft' + unless self.type_de_piece_justificative.nil? && dossier.state == 'brouillon' NotificationService.new('piece_justificative', self.dossier.id, self.libelle).notify end end diff --git a/app/views/dossiers/_dossier_show.html.haml b/app/views/dossiers/_dossier_show.html.haml index 836ba99a9..38f8eed1d 100644 --- a/app/views/dossiers/_dossier_show.html.haml +++ b/app/views/dossiers/_dossier_show.html.haml @@ -13,7 +13,7 @@ .col-xs-8.title-no-expanse .carret-right INFORMATIONS DU DEMANDEUR - - if !@current_gestionnaire && ["draft", "en_construction"].include?(@facade.dossier.state) + - if !@current_gestionnaire && ["brouillon", "en_construction"].include?(@facade.dossier.state) %a#add_siret.action{ href: users_dossier_add_siret_path(dossier_id: @facade.dossier.id) } .col-lg-4.col-md-4.col-sm-4.col-xs-4.action Renseigner un SIRET diff --git a/app/views/root/landing.html.haml b/app/views/root/landing.html.haml index 182f815b6..f74ba918f 100644 --- a/app/views/root/landing.html.haml +++ b/app/views/root/landing.html.haml @@ -89,7 +89,7 @@ dématérialisées %li.number .number-value - = number_with_delimiter(Dossier.where.not(:state => :draft).count, :locale => :fr) + = number_with_delimiter(Dossier.where.not(:state => :brouillon).count, :locale => :fr) .number-label< dossiers %br<> diff --git a/app/views/users/carte/show.html.haml b/app/views/users/carte/show.html.haml index 609611335..83761b04a 100644 --- a/app/views/users/carte/show.html.haml +++ b/app/views/users/carte/show.html.haml @@ -24,7 +24,7 @@ %input#quartier_prioritaires{ type: 'hidden', value: "#{@dossier.quartier_prioritaires.to_json}" } %input#cadastres{ type: 'hidden', value: "#{@dossier.cadastres.to_json}" } - - if @dossier.draft? + - if @dossier.brouillon? = render partial: '/layouts/etape_suivante' - else = render partial: '/layouts/modifications_terminees' diff --git a/app/views/users/description/_show.html.haml b/app/views/users/description/_show.html.haml index ec6aab933..ee18aff95 100644 --- a/app/views/users/description/_show.html.haml +++ b/app/views/users/description/_show.html.haml @@ -39,7 +39,7 @@ - if !@dossier.can_be_en_construction? .alert.alert-danger = t('errors.messages.procedure_archived') - - elsif !@dossier.draft? + - elsif !@dossier.brouillon? = render partial: '/layouts/modifications_terminees' - else = submit_tag 'Soumettre mon dossier', id: 'suivant', name: 'submit[nouveaux]', class: 'btn btn btn-success', style: 'float: right;', disabled: @procedure.archivee?, data: { disable_with: 'Soumettre votre dossier', submit: true } diff --git a/config/locales/models/dossier/fr.yml b/config/locales/models/dossier/fr.yml index c5d5b7c58..cce818522 100644 --- a/config/locales/models/dossier/fr.yml +++ b/config/locales/models/dossier/fr.yml @@ -8,7 +8,7 @@ fr: montant_aide_demande: "Le montant d'aide demandée" date_previsionnelle: "La date de début prévisionnelle" state: - draft: "Brouillon" + brouillon: "Brouillon" en_construction: "En construction" received: "En instruction" closed: "Accepté" diff --git a/lib/tasks/2017_12_04_translate_dossier_state_to_french.rake b/lib/tasks/2017_12_04_translate_dossier_state_to_french.rake index a5394c8e9..7cc59cef3 100644 --- a/lib/tasks/2017_12_04_translate_dossier_state_to_french.rake +++ b/lib/tasks/2017_12_04_translate_dossier_state_to_french.rake @@ -1,4 +1,8 @@ namespace :'2017_12_04_translate_dossier_state_to_french' do + task brouillon: :environment do + Dossier.unscoped.where(state: 'draft').update_all(state: 'brouillon') + end + task en_construction: :environment do Dossier.unscoped.where(state: 'initiated').update_all(state: 'en_construction') end diff --git a/spec/controllers/new_gestionnaire/procedures_controller_spec.rb b/spec/controllers/new_gestionnaire/procedures_controller_spec.rb index 8f9e6c530..7c27f3840 100644 --- a/spec/controllers/new_gestionnaire/procedures_controller_spec.rb +++ b/spec/controllers/new_gestionnaire/procedures_controller_spec.rb @@ -121,8 +121,8 @@ describe NewGestionnaire::ProceduresController, type: :controller do dossier end - context "with draft state" do - let(:state) { "draft" } + context "with brouillon state" do + let(:state) { "brouillon" } before { subject } it { expect(assigns(:dossiers_count_per_procedure)[procedure.id]).to eq(nil) } @@ -181,8 +181,8 @@ describe NewGestionnaire::ProceduresController, type: :controller do it { expect(assigns(:procedure)).to eq(procedure) } end - context 'with a new draft dossier' do - let!(:draft_dossier) { create(:dossier, procedure: procedure, state: 'draft') } + context 'with a new brouillon dossier' do + let!(:brouillon_dossier) { create(:dossier, procedure: procedure, state: 'draft') } before do get :show, params: { procedure_id: procedure.id } diff --git a/spec/controllers/stats_controller_spec.rb b/spec/controllers/stats_controller_spec.rb index d09c85432..29126b51a 100644 --- a/spec/controllers/stats_controller_spec.rb +++ b/spec/controllers/stats_controller_spec.rb @@ -166,7 +166,7 @@ describe StatsController, type: :controller do } end - let (:association) { Dossier.where.not(:state => :draft) } + let (:association) { Dossier.where.not(:state => :brouillon) } subject { StatsController.new.send(:dossier_instruction_mean_time, association) } @@ -218,7 +218,7 @@ describe StatsController, type: :controller do } end - let (:association) { Dossier.where.not(:state => :draft) } + let (:association) { Dossier.where.not(:state => :brouillon) } subject { StatsController.new.send(:dossier_filling_mean_time, association) } diff --git a/spec/controllers/users/description_controller_shared_example.rb b/spec/controllers/users/description_controller_shared_example.rb index 2b4ba577c..18fa3d3f3 100644 --- a/spec/controllers/users/description_controller_shared_example.rb +++ b/spec/controllers/users/description_controller_shared_example.rb @@ -31,8 +31,8 @@ shared_examples 'description_controller_spec' do it { expect(response).to have_http_status(:success) } it { expect(response.body).to_not have_content(I18n.t('errors.messages.procedure_archived')) } - context 'dossier is a draft' do - let(:state) { 'draft' } + context 'dossier is a brouillon' do + let(:state) { 'brouillon' } it { expect(response).to have_http_status(:success) } it { expect(response.body).to have_content(I18n.t('errors.messages.procedure_archived')) } @@ -115,7 +115,7 @@ shared_examples 'description_controller_spec' do subject { post :update, params: {dossier_id: dossier_id, submit: submit} } before do - dossier.draft! + dossier.brouillon! subject dossier.reload end @@ -128,7 +128,7 @@ shared_examples 'description_controller_spec' do expect(dossier.state).to eq('en_construction') end - context 'when user whould like save just a draft' do + context 'when user whould like save just a brouillon' do let(:submit) { {brouillon: 'brouillon'} } it "redirection vers la page recapitulative" do @@ -136,7 +136,7 @@ shared_examples 'description_controller_spec' do end it 'etat du dossier est soumis' do - expect(dossier.state).to eq('draft') + expect(dossier.state).to eq('brouillon') end end end @@ -153,7 +153,7 @@ shared_examples 'description_controller_spec' do end it 'etat du dossier n\'est pas soumis' do - expect(dossier.state).not_to eq('draft') + expect(dossier.state).not_to eq('brouillon') end end end @@ -313,7 +313,7 @@ shared_examples 'description_controller_spec' do it { expect(response.status).to eq(302) } context 'Le dossier est en brouillon' do - let(:state) { 'draft' } + let(:state) { 'brouillon' } it { expect(response.status).to eq(403) } end diff --git a/spec/controllers/users/dossiers_controller_spec.rb b/spec/controllers/users/dossiers_controller_spec.rb index b5c45e12a..62622a914 100644 --- a/spec/controllers/users/dossiers_controller_spec.rb +++ b/spec/controllers/users/dossiers_controller_spec.rb @@ -254,9 +254,9 @@ describe Users::DossiersController, type: :controller do expect(Dossier.last.procedure).to eq(Procedure.last) end - it 'state of dossier is draft' do + it 'state of dossier is brouillon' do subject - expect(Dossier.last.state).to eq('draft') + expect(Dossier.last.state).to eq('brouillon') end describe 'Mandataires Sociaux' do @@ -434,8 +434,8 @@ describe Users::DossiersController, type: :controller do describe 'DELETE #destroy' do let(:user) { create(:user) } - let!(:dossier_draft) { create :dossier, state: "draft", user: user } - let!(:dossier_not_draft) { create :dossier, state: "en_construction", user: user } + let!(:dossier_brouillon) { create :dossier, state: "brouillon", user: user } + let!(:dossier_not_brouillon) { create :dossier, state: "en_construction", user: user } subject { delete :destroy, params: {id: dossier.id} } @@ -443,8 +443,8 @@ describe Users::DossiersController, type: :controller do sign_in user end - context 'when dossier is draft' do - let(:dossier) { dossier_draft } + context 'when dossier is brouillon' do + let(:dossier) { dossier_brouillon } it { expect(subject.status).to eq 302 } @@ -464,8 +464,8 @@ describe Users::DossiersController, type: :controller do it { expect { subject }.to change { Dossier.count }.by(-1) } end - context 'when dossier is not a draft' do - let(:dossier) { dossier_not_draft } + context 'when dossier is not a brouillon' do + let(:dossier) { dossier_not_brouillon } it { expect { subject }.to change { Dossier.count }.by(0) } end diff --git a/spec/controllers/users/recapitulatif_controller_spec.rb b/spec/controllers/users/recapitulatif_controller_spec.rb index d4ee814a9..9c35377e1 100644 --- a/spec/controllers/users/recapitulatif_controller_spec.rb +++ b/spec/controllers/users/recapitulatif_controller_spec.rb @@ -22,9 +22,9 @@ describe Users::RecapitulatifController, type: :controller do it_behaves_like "not owner of dossier", :show describe 'before_action authorized_routes?' do - context 'when dossier have draft state' do + context 'when dossier have brouillon state' do before do - dossier.state = 'draft' + dossier.state = 'brouillon' dossier.save get :show, params: {dossier_id: dossier.id} diff --git a/spec/decorators/dossier_decorator_spec.rb b/spec/decorators/dossier_decorator_spec.rb index 64ac28aa8..fe5ca2c36 100644 --- a/spec/decorators/dossier_decorator_spec.rb +++ b/spec/decorators/dossier_decorator_spec.rb @@ -22,8 +22,8 @@ describe DossierDecorator do describe 'state_fr' do subject{ super().display_state } - it 'draft is brouillon' do - dossier.draft! + it 'brouillon is brouillon' do + dossier.brouillon! expect(subject).to eq('Brouillon') end @@ -63,7 +63,7 @@ describe DossierDecorator do context "when a gestionnaire is not signed_in" do context "when the dossier is in brouillon state" do before do - dossier.state = 'draft' + dossier.state = 'brouillon' dossier.save end diff --git a/spec/facades/admin_procedures_show_facades_spec.rb b/spec/facades/admin_procedures_show_facades_spec.rb index c1cf99841..af7323e54 100644 --- a/spec/facades/admin_procedures_show_facades_spec.rb +++ b/spec/facades/admin_procedures_show_facades_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe AdminProceduresShowFacades do let!(:procedure) { create(:procedure) } - let!(:dossier_0) { create(:dossier, procedure: procedure, state: 'draft') } + let!(:dossier_0) { create(:dossier, procedure: procedure, state: 'brouillon') } let!(:dossier_1) { create(:dossier, procedure: procedure, state: 'en_construction') } let!(:dossier_2) { create(:dossier, procedure: procedure, state: 'en_construction') } let!(:dossier_6) { create(:dossier, procedure: procedure, archived: true, state: 'en_construction') } diff --git a/spec/factories/dossier.rb b/spec/factories/dossier.rb index afab7d294..3bfcf7d17 100644 --- a/spec/factories/dossier.rb +++ b/spec/factories/dossier.rb @@ -1,6 +1,6 @@ FactoryGirl.define do factory :dossier do - state 'draft' + state 'brouillon' association :user, factory: [:user] before(:create) do |dossier, _evaluator| diff --git a/spec/jobs/auto_archive_procedure_job_spec.rb b/spec/jobs/auto_archive_procedure_job_spec.rb index d4b0102d6..f279aac4f 100644 --- a/spec/jobs/auto_archive_procedure_job_spec.rb +++ b/spec/jobs/auto_archive_procedure_job_spec.rb @@ -18,7 +18,7 @@ RSpec.describe AutoArchiveProcedureJob, type: :job do end context "when procedures have auto_archive_on set on yesterday or today" do - let!(:dossier1) { create(:dossier, procedure: procedure_hier, state: 'draft', archived: false)} + let!(:dossier1) { create(:dossier, procedure: procedure_hier, state: 'brouillon', archived: false)} let!(:dossier2) { create(:dossier, procedure: procedure_hier, state: 'en_construction', archived: false)} let!(:dossier3) { create(:dossier, procedure: procedure_hier, state: 'en_construction', archived: false)} let!(:dossier4) { create(:dossier, procedure: procedure_hier, state: 'en_construction', archived: false)} @@ -39,7 +39,7 @@ RSpec.describe AutoArchiveProcedureJob, type: :job do procedure_aujourdhui.reload end - it { expect(dossier1.state).to eq 'draft' } + it { expect(dossier1.state).to eq 'brouillon' } it { expect(dossier2.state).to eq 'received' } it { expect(dossier3.state).to eq 'received' } it { expect(dossier4.state).to eq 'received' } diff --git a/spec/jobs/auto_receive_dossiers_for_procedure_job_spec.rb b/spec/jobs/auto_receive_dossiers_for_procedure_job_spec.rb index bfee9e2e7..5fbade2cc 100644 --- a/spec/jobs/auto_receive_dossiers_for_procedure_job_spec.rb +++ b/spec/jobs/auto_receive_dossiers_for_procedure_job_spec.rb @@ -13,8 +13,8 @@ RSpec.describe AutoReceiveDossiersForProcedureJob, type: :job do let(:nouveau_dossier1) { create(:dossier, :en_construction) } let(:nouveau_dossier2) { create(:dossier, :en_construction, procedure: nouveau_dossier1.procedure) } let(:dossier_recu) { create(:dossier, :received, procedure: nouveau_dossier2.procedure) } - let(:dossier_draft) { create(:dossier, procedure: dossier_recu.procedure) } - let(:procedure_id) { dossier_draft.procedure_id } + let(:dossier_brouillon) { create(:dossier, procedure: dossier_recu.procedure) } + let(:procedure_id) { dossier_brouillon.procedure_id } it do subject @@ -27,8 +27,8 @@ RSpec.describe AutoReceiveDossiersForProcedureJob, type: :job do expect(dossier_recu.reload.received?).to be true expect(dossier_recu.reload.received_at).to eq(date) - expect(dossier_draft.reload.draft?).to be true - expect(dossier_draft.reload.received_at).to eq(nil) + expect(dossier_brouillon.reload.brouillon?).to be true + expect(dossier_brouillon.reload.received_at).to eq(nil) end end end diff --git a/spec/models/dossier_spec.rb b/spec/models/dossier_spec.rb index b4c215b04..ba7d7f760 100644 --- a/spec/models/dossier_spec.rb +++ b/spec/models/dossier_spec.rb @@ -134,9 +134,9 @@ describe Dossier do it { expect { subject }.to raise_error('role is not valid') } end - context 'when dossier is at state draft' do + context 'when dossier is at state brouillon' do before do - dossier.draft! + dossier.brouillon! end context 'when user is connected' do @@ -145,13 +145,13 @@ describe Dossier do context 'when he updates dossier informations' do let(:action) { 'update' } - it { is_expected.to eq('draft') } + it { is_expected.to eq('brouillon') } end context 'when he posts a comment' do let(:action) { 'comment' } - it { is_expected.to eq('draft') } + it { is_expected.to eq('brouillon') } end context 'when he initiate a dossier' do @@ -421,7 +421,7 @@ describe Dossier do it { expect(subject[3]).to be_in([true, false]) } it { expect(subject[4]).to eq(dossier.user.email) } it { expect(subject[5]).to be_in([true, false]) } - it { expect(subject[6]).to eq("draft") } + it { expect(subject[6]).to eq("brouillon") } it { expect(subject[7]).to eq(date1) } it { expect(subject[8]).to eq(date2) } it { expect(subject[9]).to eq(date3) } @@ -459,7 +459,7 @@ describe Dossier do "false", dossier.user.email, "false", - "draft", + "brouillon", dossier.en_construction_at, dossier.received_at, dossier.processed_at, @@ -624,7 +624,7 @@ describe Dossier do end context 'when the dossier has not been en_construction' do - let(:dossier) { create :dossier, procedure: procedure, state: 'draft' } + let(:dossier) { create :dossier, procedure: procedure, state: 'brouillon' } subject { dossier.text_summary } @@ -683,7 +683,7 @@ describe Dossier do end describe '#update_state_dates' do - let(:state) { 'draft' } + let(:state) { 'brouillon' } let(:dossier) { create(:dossier, state: state) } let(:beginning_of_day) { Time.now.beginning_of_day } @@ -760,7 +760,7 @@ describe Dossier do describe '.downloadable_sorted' do let(:procedure) { create(:procedure) } - let!(:dossier) { create(:dossier, :with_entreprise, procedure: procedure, state: :draft) } + let!(:dossier) { create(:dossier, :with_entreprise, procedure: procedure, state: :brouillon) } let!(:dossier2) { create(:dossier, :with_entreprise, procedure: procedure, state: :en_construction, en_construction_at: DateTime.parse('03/01/2010')) } let!(:dossier3) { create(:dossier, :with_entreprise, procedure: procedure, state: :received, en_construction_at: DateTime.parse('01/01/2010')) } let!(:dossier4) { create(:dossier, :with_entreprise, procedure: procedure, state: :received, archived: true, en_construction_at: DateTime.parse('02/01/2010')) } @@ -798,13 +798,13 @@ describe Dossier do end it "send an email when the dossier is created for the very first time" do - expect { Dossier.create(procedure: procedure, state: "draft", user: user) }.to change(ActionMailer::Base.deliveries, :size).from(0).to(1) + expect { Dossier.create(procedure: procedure, state: "brouillon", user: user) }.to change(ActionMailer::Base.deliveries, :size).from(0).to(1) mail = ActionMailer::Base.deliveries.last expect(mail.subject).to eq("Retrouvez votre brouillon pour la démarche : #{procedure.libelle}") end - it "does not send an email when the dossier is created with a non draft state" do + it "does not send an email when the dossier is created with a non brouillon state" do expect { Dossier.create(procedure: procedure, state: "en_construction", user: user) }.not_to change(ActionMailer::Base.deliveries, :size) expect { Dossier.create(procedure: procedure, state: "received", user: user) }.not_to change(ActionMailer::Base.deliveries, :size) expect { Dossier.create(procedure: procedure, state: "closed", user: user) }.not_to change(ActionMailer::Base.deliveries, :size) diff --git a/spec/models/procedure_overview_spec.rb b/spec/models/procedure_overview_spec.rb index 87022be45..61460247e 100644 --- a/spec/models/procedure_overview_spec.rb +++ b/spec/models/procedure_overview_spec.rb @@ -45,8 +45,8 @@ describe ProcedureOverview, type: :model do create(:dossier, procedure: procedure, created_at: monday, state: :received) end - let!(:created_dossier_during_the_week_but_in_draft) do - create(:dossier, procedure: procedure, created_at: monday, state: :draft) + let!(:created_dossier_during_the_week_but_in_brouillon) do + create(:dossier, procedure: procedure, created_at: monday, state: :brouillon) end let!(:created_dossier_before_the_week) do diff --git a/spec/models/procedure_spec.rb b/spec/models/procedure_spec.rb index 44e6b4a5f..1ff279498 100644 --- a/spec/models/procedure_spec.rb +++ b/spec/models/procedure_spec.rb @@ -308,7 +308,7 @@ describe Procedure do before do create :dossier, procedure: procedure, state: :en_construction - create :dossier, procedure: procedure, state: :draft + create :dossier, procedure: procedure, state: :brouillon create :dossier, procedure: procedure, state: :en_construction end @@ -371,8 +371,8 @@ describe Procedure do end end - context 'when there is a draft dossier' do - let!(:dossier_not_exportable){ create(:dossier, procedure: procedure, state: 'draft') } + context 'when there is a brouillon dossier' do + let!(:dossier_not_exportable){ create(:dossier, procedure: procedure, state: 'brouillon') } it_behaves_like "export is empty" end diff --git a/spec/models/search_spec.rb b/spec/models/search_spec.rb index a2249d804..184de9442 100644 --- a/spec/models/search_spec.rb +++ b/spec/models/search_spec.rb @@ -22,7 +22,7 @@ describe Search do let(:procedure_1) { create(:procedure, :published, administrateur: administrateur_1) } let(:procedure_2) { create(:procedure, :published, administrateur: administrateur_2) } - let!(:dossier_0) { create(:dossier, state: 'draft', procedure: procedure_1, user: create(:user, email: 'brouillon@clap.fr')) } + let!(:dossier_0) { create(:dossier, state: 'brouillon', procedure: procedure_1, user: create(:user, email: 'brouillon@clap.fr')) } let!(:dossier_1) { create(:dossier, state: 'en_construction', procedure: procedure_1, user: create(:user, email: 'contact@test.com')) } let!(:dossier_2) { create(:dossier, state: 'en_construction', procedure: procedure_1, user: create(:user, email: 'plop@gmail.com')) } let!(:dossier_3) { create(:dossier, state: 'en_construction', procedure: procedure_2, user: create(:user, email: 'peace@clap.fr')) } @@ -38,7 +38,7 @@ describe Search do it { expect(subject.size).to eq(0) } end - describe 'search draft file' do + describe 'search brouillon file' do let(:terms) { 'brouillon' } it { expect(subject.size).to eq(0) } diff --git a/spec/services/dossiers_list_gestionnaire_service_spec.rb b/spec/services/dossiers_list_gestionnaire_service_spec.rb index 679603008..310dca8f3 100644 --- a/spec/services/dossiers_list_gestionnaire_service_spec.rb +++ b/spec/services/dossiers_list_gestionnaire_service_spec.rb @@ -345,7 +345,7 @@ describe DossiersListGestionnaireService do describe 'state filter methods' do let!(:procedure) { create :procedure } - let!(:dossier) { create(:dossier, procedure: procedure, state: 'draft') } + let!(:dossier) { create(:dossier, procedure: procedure, state: 'brouillon') } let!(:dossier2) { create(:dossier, procedure: procedure, state: 'en_construction') } #nouveaux let!(:dossier3) { create(:dossier, procedure: procedure, state: 'en_construction') } #nouveaux let!(:dossier6) { create(:dossier, procedure: procedure, state: 'received') } #a_instruire diff --git a/spec/services/user_routes_authorization_service_spec.rb b/spec/services/user_routes_authorization_service_spec.rb index 8fd8a2d2c..f3c872a1e 100644 --- a/spec/services/user_routes_authorization_service_spec.rb +++ b/spec/services/user_routes_authorization_service_spec.rb @@ -13,8 +13,8 @@ describe UserRoutesAuthorizationService do describe 'Users::DossiersController' do let(:controller) { Users::DossiersController } - describe 'draft' do - let(:state) { 'draft' } + describe 'brouillon' do + let(:state) { 'brouillon' } it { is_expected.to be_truthy } end @@ -33,8 +33,8 @@ describe UserRoutesAuthorizationService do let(:controller) { Users::CarteController } context 'when use_api_carto is false' do - describe 'draft' do - let(:state) { 'draft' } + describe 'brouillon' do + let(:state) { 'brouillon' } it { is_expected.to be_falsey } end @@ -52,8 +52,8 @@ describe UserRoutesAuthorizationService do context 'when use_api_carto is true' do let(:use_api_carto) { true } - describe 'draft' do - let(:state) { 'draft' } + describe 'brouillon' do + let(:state) { 'brouillon' } it { is_expected.to be_truthy } end @@ -72,8 +72,8 @@ describe UserRoutesAuthorizationService do describe 'Users::DescriptionController' do let(:controller) { Users::DescriptionController } - describe 'draft' do - let(:state) { 'draft' } + describe 'brouillon' do + let(:state) { 'brouillon' } it { is_expected.to be_truthy } end @@ -91,8 +91,8 @@ describe UserRoutesAuthorizationService do describe 'recapitulatif' do let(:controller) { Users::RecapitulatifController } - describe 'draft' do - let(:state) { 'draft' } + describe 'brouillon' do + let(:state) { 'brouillon' } it { is_expected.to be_falsey } end diff --git a/spec/views/layouts/left_panels/_left_panel_backoffice_dossierscontroller_show_spec.rb b/spec/views/layouts/left_panels/_left_panel_backoffice_dossierscontroller_show_spec.rb index f0372a04e..fb73c1fd1 100644 --- a/spec/views/layouts/left_panels/_left_panel_backoffice_dossierscontroller_show_spec.rb +++ b/spec/views/layouts/left_panels/_left_panel_backoffice_dossierscontroller_show_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe 'layouts/left_panels/_left_panel_backoffice_dossierscontroller_show.html.haml', type: :view do let!(:dossier) { create(:dossier, :with_entreprise, state: state, archived: archived) } - let(:state) { 'draft' } + let(:state) { 'brouillon' } let(:archived) { false } let(:gestionnaire) { create(:gestionnaire) } let!(:assign_to) { create(:assign_to, gestionnaire: gestionnaire, procedure: dossier.procedure) } diff --git a/spec/views/layouts/left_panels/_left_panel_users_recapitulatifcontroller_show_spec.rb b/spec/views/layouts/left_panels/_left_panel_users_recapitulatifcontroller_show_spec.rb index 2e1ba02c2..5a7f167b5 100644 --- a/spec/views/layouts/left_panels/_left_panel_users_recapitulatifcontroller_show_spec.rb +++ b/spec/views/layouts/left_panels/_left_panel_users_recapitulatifcontroller_show_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe 'layouts/left_panels/_left_panel_users_recapitulatifcontroller_show.html.haml', type: :view do let(:dossier) { create(:dossier, :with_entreprise, state: state, procedure: create(:procedure, :with_api_carto, :with_two_type_de_piece_justificative, for_individual: true, individual_with_siret: true)) } let(:dossier_id) { dossier.id } - let(:state) { 'draft' } + let(:state) { 'brouillon' } before do sign_in dossier.user diff --git a/spec/views/users/carte/show.html.haml_spec.rb b/spec/views/users/carte/show.html.haml_spec.rb index 6383ad295..46a90c5cf 100644 --- a/spec/views/users/carte/show.html.haml_spec.rb +++ b/spec/views/users/carte/show.html.haml_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe 'users/carte/show.html.haml', type: :view do - let(:state) { 'draft' } + let(:state) { 'brouillon' } let(:dossier) { create(:dossier, state: state) } let(:dossier_id) { dossier.id } diff --git a/spec/views/users/recapitulatif/show.html.haml_spec.rb b/spec/views/users/recapitulatif/show.html.haml_spec.rb index b6e1de965..27c86c652 100644 --- a/spec/views/users/recapitulatif/show.html.haml_spec.rb +++ b/spec/views/users/recapitulatif/show.html.haml_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe 'users/recapitulatif/show.html.haml', type: :view do let(:dossier) { create(:dossier, :with_entreprise, state: state, procedure: create(:procedure, :with_api_carto, :with_two_type_de_piece_justificative, for_individual: true, individual_with_siret: true)) } let(:dossier_id) { dossier.id } - let(:state) { 'draft' } + let(:state) { 'brouillon' } before do sign_in dossier.user