From 56545933a92662a3eab5bc0db4df75bff40ce57b Mon Sep 17 00:00:00 2001 From: LeSim Date: Thu, 14 Dec 2017 15:51:45 +0100 Subject: [PATCH] [fix #504] Dossier: initiated -> en_construction The change must not impact the api --- .../backoffice/dossiers_controller.rb | 2 +- .../new_gestionnaire/dossiers_controller.rb | 2 +- app/controllers/stats_controller.rb | 8 +-- app/controllers/users/carte_controller.rb | 2 +- .../users/description_controller.rb | 8 +-- .../users/recapitulatif_controller.rb | 2 +- app/models/dossier.rb | 18 +++--- app/models/procedure_overview.rb | 2 +- app/serializers/dossier_serializer.rb | 13 +++++ .../dossier_table_export_serializer.rb | 13 +++++ app/serializers/dossiers_serializer.rb | 4 ++ app/views/dossiers/_dossier_show.html.haml | 2 +- ...ckoffice_dossierscontroller_show.html.haml | 2 +- app/views/users/description/_show.html.haml | 2 +- config/locales/models/dossier/fr.yml | 2 +- ...me_dossier_initiated_by_en_construction.rb | 5 ++ db/schema.rb | 4 +- ..._04_translate_dossier_state_to_french.rake | 5 ++ .../api/v1/dossiers_controller_spec.rb | 6 +- .../commentaires_controller_spec.rb | 6 +- .../dossiers/procedure_controller_spec.rb | 2 +- .../backoffice/dossiers_controller_spec.rb | 10 ++-- .../private_formulaires_controller_spec.rb | 2 +- spec/controllers/invites_controller_spec.rb | 2 +- .../new_gestionnaire/avis_controller_spec.rb | 2 +- .../dossiers_controller_spec.rb | 14 ++--- .../procedures_controller_spec.rb | 6 +- .../recherche_controller_spec.rb | 6 +- spec/controllers/stats_controller_spec.rb | 32 +++++----- .../users/carte_controller_shared_example.rb | 2 +- .../description_controller_shared_example.rb | 4 +- .../users/description_controller_spec.rb | 2 +- .../users/dossiers_controller_spec.rb | 2 +- .../users/recapitulatif_controller_spec.rb | 6 +- spec/decorators/dossier_decorator_spec.rb | 6 +- .../admin_procedures_show_facades_spec.rb | 8 +-- spec/factories/dossier.rb | 8 +-- .../backoffice/add_commentaire_spec.rb | 2 +- .../backoffice/flux_de_commentaires_spec.rb | 2 +- .../backoffice/index_show_procedure_spec.rb | 2 +- ..._page_pref_list_dossier_backoffice_spec.rb | 2 +- ...st_dossier_by_procedure_backoffice_spec.rb | 2 +- .../backoffice/navigate_to_dossier_spec.rb | 6 +- spec/features/backoffice/search_file_spec.rb | 4 +- .../new_gestionnaire/gestionnaire_spec.rb | 2 +- spec/features/users/dossier_edition_spec.rb | 2 +- spec/features/users/dossier_index_spec.rb | 2 +- .../users/flux_de_commentaires_spec.rb | 2 +- spec/features/users/list_dossiers_spec.rb | 6 +- spec/features/users/onglets_link_spec.rb | 4 +- spec/jobs/auto_archive_procedure_job_spec.rb | 8 +-- ...receive_dossiers_for_procedure_job_spec.rb | 4 +- spec/models/dossier_spec.rb | 58 +++++++++---------- spec/models/gestionnaire_spec.rb | 12 ++-- spec/models/procedure_overview_spec.rb | 2 +- spec/models/procedure_spec.rb | 6 +- spec/models/search_spec.rb | 8 +-- spec/serializers/dossier_serializer_spec.rb | 12 ++++ .../dossier_table_export_serializer_spec.rb | 11 ++++ spec/serializers/dossiers_serializer_spec.rb | 11 ++++ ...dossiers_list_gestionnaire_service_spec.rb | 6 +- .../user_routes_authorization_service_spec.rb | 20 +++---- .../previsualisations/show.html.haml_spec.rb | 2 +- .../dossiers/index_html.haml_spec.rb | 2 +- ...backoffice_dossierscontroller_show_spec.rb | 4 +- ...users_recapitulatifcontroller_show_spec.rb | 4 +- .../dossiers/show.html.haml_spec.rb | 2 +- .../_download_dossiers.html.haml_spec.rb | 2 +- spec/views/users/carte/show.html.haml_spec.rb | 2 +- .../users/description/show.html.haml_spec.rb | 2 +- .../users/dossiers/index_html.haml_spec.rb | 6 +- .../recapitulatif/show.html.haml_spec.rb | 4 +- 72 files changed, 261 insertions(+), 187 deletions(-) create mode 100644 db/migrate/20171214112701_rename_dossier_initiated_by_en_construction.rb create mode 100644 lib/tasks/2017_12_04_translate_dossier_state_to_french.rake create mode 100644 spec/serializers/dossier_serializer_spec.rb create mode 100644 spec/serializers/dossiers_serializer_spec.rb diff --git a/app/controllers/backoffice/dossiers_controller.rb b/app/controllers/backoffice/dossiers_controller.rb index 5acaa4fa8..da119375f 100644 --- a/app/controllers/backoffice/dossiers_controller.rb +++ b/app/controllers/backoffice/dossiers_controller.rb @@ -179,7 +179,7 @@ class Backoffice::DossiersController < Backoffice::DossiersListController def reopen create_dossier_facade params[:dossier_id] - @facade.dossier.initiated! + @facade.dossier.en_construction! flash.notice = 'Dossier repassé en construction.' redirect_to backoffice_dossier_path(id: @facade.dossier.id) diff --git a/app/controllers/new_gestionnaire/dossiers_controller.rb b/app/controllers/new_gestionnaire/dossiers_controller.rb index 6f78b3bff..622d072bb 100644 --- a/app/controllers/new_gestionnaire/dossiers_controller.rb +++ b/app/controllers/new_gestionnaire/dossiers_controller.rb @@ -69,7 +69,7 @@ module NewGestionnaire end def repasser_en_construction - dossier.initiated! + dossier.en_construction! flash.notice = 'Dossier repassé en construction.' redirect_to dossier_path(procedure, dossier) diff --git a/app/controllers/stats_controller.rb b/app/controllers/stats_controller.rb index 766a4fb2f..5936fcdcf 100644 --- a/app/controllers/stats_controller.rb +++ b/app/controllers/stats_controller.rb @@ -13,8 +13,8 @@ class StatsController < ApplicationController @procedures_cumulative = cumulative_hash(procedures, :published_at) @procedures_in_the_last_4_months = last_four_months_hash(procedures, :published_at) - @dossiers_cumulative = cumulative_hash(dossiers, :initiated_at) - @dossiers_in_the_last_4_months = last_four_months_hash(dossiers, :initiated_at) + @dossiers_cumulative = cumulative_hash(dossiers, :en_construction_at) + @dossiers_in_the_last_4_months = last_four_months_hash(dossiers, :en_construction_at) @procedures_count_per_administrateur = procedures_count_per_administrateur(procedures) @@ -96,7 +96,7 @@ class StatsController < ApplicationController processed_dossiers = dossiers .where(:processed_at => min_date..max_date) - .pluck(:procedure_id, :initiated_at, :processed_at) + .pluck(:procedure_id, :en_construction_at, :processed_at) # Group dossiers by month processed_dossiers_by_month = processed_dossiers @@ -137,7 +137,7 @@ class StatsController < ApplicationController processed_dossiers = dossiers .where(:processed_at => min_date..max_date) - .pluck(:procedure_id, :created_at, :initiated_at, :processed_at) + .pluck(:procedure_id, :created_at, :en_construction_at, :processed_at) # Group dossiers by month processed_dossiers_by_month = processed_dossiers diff --git a/app/controllers/users/carte_controller.rb b/app/controllers/users/carte_controller.rb index a281cab58..d296d5665 100644 --- a/app/controllers/users/carte_controller.rb +++ b/app/controllers/users/carte_controller.rb @@ -61,7 +61,7 @@ class Users::CarteController < UsersController def self.route_authorization { - states: [:draft, :initiated], + states: [:draft, :en_construction], api_carto: true } end diff --git a/app/controllers/users/description_controller.rb b/app/controllers/users/description_controller.rb index f83751f33..0fc4489c9 100644 --- a/app/controllers/users/description_controller.rb +++ b/app/controllers/users/description_controller.rb @@ -14,7 +14,7 @@ class Users::DescriptionController < UsersController @headers = @champs.select { |c| c.type_champ == 'header_section' } - unless @dossier.can_be_initiated? + unless @dossier.can_be_en_construction? flash[:alert] = t('errors.messages.procedure_archived') end @@ -27,7 +27,7 @@ class Users::DescriptionController < UsersController dossier = current_user_dossier procedure = dossier.procedure - return head :forbidden unless dossier.can_be_initiated? + return head :forbidden unless dossier.can_be_en_construction? ChampsService.save_champs(dossier.champs, params) if params[:champs] @@ -51,8 +51,8 @@ class Users::DescriptionController < UsersController redirect_to url_for(controller: :dossiers, action: :index, liste: :brouillon) else if dossier.draft? - dossier.initiated! NotificationMailer.send_notification(dossier, procedure.initiated_mail_template).deliver_now! + dossier.en_construction! end flash.notice = 'Félicitations, votre demande a bien été enregistrée.' redirect_to url_for(controller: :recapitulatif, action: :show, dossier_id: dossier.id) @@ -93,7 +93,7 @@ class Users::DescriptionController < UsersController def self.route_authorization { - states: [:draft, :initiated] + states: [:draft, :en_construction] } end diff --git a/app/controllers/users/recapitulatif_controller.rb b/app/controllers/users/recapitulatif_controller.rb index 5066c9dc1..7614a16c9 100644 --- a/app/controllers/users/recapitulatif_controller.rb +++ b/app/controllers/users/recapitulatif_controller.rb @@ -18,7 +18,7 @@ class Users::RecapitulatifController < UsersController def self.route_authorization { - states: [:initiated, :received, :without_continuation, :closed, :refused] + states: [:en_construction, :received, :without_continuation, :closed, :refused] } end diff --git a/app/models/dossier.rb b/app/models/dossier.rb index 3b4a9f522..38848b077 100644 --- a/app/models/dossier.rb +++ b/app/models/dossier.rb @@ -1,7 +1,7 @@ class Dossier < ActiveRecord::Base enum state: { draft: 'draft', - initiated: 'initiated', + en_construction: 'en_construction', received: 'received', closed: 'closed', refused: 'refused', @@ -9,8 +9,8 @@ class Dossier < ActiveRecord::Base } BROUILLON = %w(draft) - NOUVEAUX = %w(initiated) - EN_CONSTRUCTION = %w(initiated) + NOUVEAUX = %w(en_construction) + EN_CONSTRUCTION = %w(en_construction) EN_INSTRUCTION = %w(received) EN_CONSTRUCTION_OU_INSTRUCTION = EN_CONSTRUCTION + EN_INSTRUCTION TERMINE = %w(closed refused without_continuation) @@ -58,7 +58,7 @@ class Dossier < ActiveRecord::Base scope :nouveaux, -> { not_archived.state_nouveaux } scope :en_instruction, -> { not_archived.state_en_instruction } scope :termine, -> { not_archived.state_termine } - scope :downloadable_sorted, -> { state_not_brouillon.includes(:entreprise, :etablissement, :champs, :champs_private).order(initiated_at: 'asc') } + scope :downloadable_sorted, -> { state_not_brouillon.includes(:entreprise, :etablissement, :champs, :champs_private).order(en_construction_at: 'asc') } scope :en_cours, -> { not_archived.state_en_construction_ou_instruction } scope :without_followers, -> { left_outer_joins(:follows).where(follows: { id: nil }) } scope :with_unread_notifications, -> { where(notifications: { already_read: false }) } @@ -158,7 +158,7 @@ class Dossier < ActiveRecord::Base case action when 'initiate' if draft? - initiated! + en_construction! end end when 'gestionnaire' @@ -294,7 +294,7 @@ class Dossier < ActiveRecord::Base (invites_user.pluck :email).include? email end - def can_be_initiated? + def can_be_en_construction? !(procedure.archivee? && draft?) end @@ -309,7 +309,7 @@ class Dossier < ActiveRecord::Base else parts = [ "Dossier déposé le ", - initiated_at.localtime.strftime("%d/%m/%Y"), + en_construction_at.localtime.strftime("%d/%m/%Y"), " sur la procédure ", procedure.libelle, " gérée par l'organisme ", @@ -388,8 +388,8 @@ class Dossier < ActiveRecord::Base end def update_state_dates - if initiated? && !self.initiated_at - self.initiated_at = DateTime.now + if en_construction? && !self.en_construction_at + self.en_construction_at = DateTime.now elsif received? && !self.received_at self.received_at = DateTime.now elsif TERMINE.include?(state) diff --git a/app/models/procedure_overview.rb b/app/models/procedure_overview.rb index c614bf4a3..fc4aef79d 100644 --- a/app/models/procedure_overview.rb +++ b/app/models/procedure_overview.rb @@ -20,7 +20,7 @@ class ProcedureOverview @old_dossiers_en_construction = procedure .dossiers .state_en_construction - .where('initiated_at < ?', 1.week.ago) + .where('en_construction_at < ?', 1.week.ago) @created_dossiers_count = procedure .dossiers diff --git a/app/serializers/dossier_serializer.rb b/app/serializers/dossier_serializer.rb index 9de70e415..46cf77634 100644 --- a/app/serializers/dossier_serializer.rb +++ b/app/serializers/dossier_serializer.rb @@ -35,10 +35,23 @@ class DossierSerializer < ActiveModel::Serializer object.user.try(:email) end + def state + case object.state + when 'en_construction' + 'initiated' + else + object.state + end + end + def simplified_state object.decorate.display_state end + def initiated_at + object.en_construction_at + end + def accompagnateurs object.followers_gestionnaires.pluck(:email) end diff --git a/app/serializers/dossier_table_export_serializer.rb b/app/serializers/dossier_table_export_serializer.rb index 00bf65a49..7da5846aa 100644 --- a/app/serializers/dossier_table_export_serializer.rb +++ b/app/serializers/dossier_table_export_serializer.rb @@ -22,6 +22,19 @@ class DossierTableExportSerializer < ActiveModel::Serializer object.user.try(:email) end + def state + case object.state + when 'en_construction' + 'initiated' + else + object.state + end + end + + def initiated_at + object.en_construction_at + end + def individual_prenom object.individual.try(:prenom) end diff --git a/app/serializers/dossiers_serializer.rb b/app/serializers/dossiers_serializer.rb index 34110603e..98fa3cfb0 100644 --- a/app/serializers/dossiers_serializer.rb +++ b/app/serializers/dossiers_serializer.rb @@ -2,4 +2,8 @@ class DossiersSerializer < ActiveModel::Serializer attributes :id, :updated_at, :initiated_at + + def initiated_at + object.en_construction_at + end end diff --git a/app/views/dossiers/_dossier_show.html.haml b/app/views/dossiers/_dossier_show.html.haml index 09f09cd99..836ba99a9 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", "initiated"].include?(@facade.dossier.state) + - if !@current_gestionnaire && ["draft", "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/layouts/left_panels/_left_panel_backoffice_dossierscontroller_show.html.haml b/app/views/layouts/left_panels/_left_panel_backoffice_dossierscontroller_show.html.haml index 3455a0223..18806388c 100644 --- a/app/views/layouts/left_panels/_left_panel_backoffice_dossierscontroller_show.html.haml +++ b/app/views/layouts/left_panels/_left_panel_backoffice_dossierscontroller_show.html.haml @@ -4,7 +4,7 @@ - if current_gestionnaire && current_gestionnaire.assigned_on_procedure?(@facade.dossier.procedure_id) #action-block - - if !@facade.dossier.read_only? || @facade.dossier.initiated? + - if !@facade.dossier.read_only? || @facade.dossier.en_construction? = link_to 'Passer en instruction', backoffice_dossier_receive_path(@facade.dossier), method: :post, class: 'btn btn-danger btn-block', data: { confirm: "Confirmer vous le passage en instruction de ce dossier ?" } - elsif @facade.dossier.received? diff --git a/app/views/users/description/_show.html.haml b/app/views/users/description/_show.html.haml index aac70c2f8..ec6aab933 100644 --- a/app/views/users/description/_show.html.haml +++ b/app/views/users/description/_show.html.haml @@ -36,7 +36,7 @@ %div{ style: 'text-align: right;' } %h6 Tous les champs portant un * sont obligatoires. - - if !@dossier.can_be_initiated? + - if !@dossier.can_be_en_construction? .alert.alert-danger = t('errors.messages.procedure_archived') - elsif !@dossier.draft? diff --git a/config/locales/models/dossier/fr.yml b/config/locales/models/dossier/fr.yml index c24c200b1..c5d5b7c58 100644 --- a/config/locales/models/dossier/fr.yml +++ b/config/locales/models/dossier/fr.yml @@ -9,7 +9,7 @@ fr: date_previsionnelle: "La date de début prévisionnelle" state: draft: "Brouillon" - initiated: "En construction" + en_construction: "En construction" received: "En instruction" closed: "Accepté" refused: "Refusé" diff --git a/db/migrate/20171214112701_rename_dossier_initiated_by_en_construction.rb b/db/migrate/20171214112701_rename_dossier_initiated_by_en_construction.rb new file mode 100644 index 000000000..e547434cd --- /dev/null +++ b/db/migrate/20171214112701_rename_dossier_initiated_by_en_construction.rb @@ -0,0 +1,5 @@ +class RenameDossierInitiatedByEnConstruction < ActiveRecord::Migration[5.0] + def change + rename_column :dossiers, :initiated_at, :en_construction_at + end +end diff --git a/db/schema.rb b/db/schema.rb index b7070879b..38457f5e5 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20171205151128) do +ActiveRecord::Schema.define(version: 20171214112701) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -194,7 +194,7 @@ ActiveRecord::Schema.define(version: 20171205151128) do t.text "json_latlngs" t.boolean "archived", default: false t.boolean "mandataire_social", default: false - t.datetime "initiated_at" + t.datetime "en_construction_at" t.datetime "received_at" t.datetime "processed_at" t.text "motivation" 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 new file mode 100644 index 000000000..a5394c8e9 --- /dev/null +++ b/lib/tasks/2017_12_04_translate_dossier_state_to_french.rake @@ -0,0 +1,5 @@ +namespace :'2017_12_04_translate_dossier_state_to_french' do + task en_construction: :environment do + Dossier.unscoped.where(state: 'initiated').update_all(state: 'en_construction') + end +end diff --git a/spec/controllers/api/v1/dossiers_controller_spec.rb b/spec/controllers/api/v1/dossiers_controller_spec.rb index 98fb7b4d4..c6f2509df 100644 --- a/spec/controllers/api/v1/dossiers_controller_spec.rb +++ b/spec/controllers/api/v1/dossiers_controller_spec.rb @@ -25,7 +25,7 @@ describe API::V1::DossiersController do context 'when procedure is found and belongs to admin' do let(:procedure_id) { procedure.id } let(:date_creation) { Time.utc(2008, 9, 1, 10, 5, 0) } - let!(:dossier) { Timecop.freeze(date_creation) { create(:dossier, :with_entreprise, :initiated, procedure: procedure) } } + let!(:dossier) { Timecop.freeze(date_creation) { create(:dossier, :with_entreprise, :en_construction, procedure: procedure) } } let(:body) { JSON.parse(retour.body, symbolize_names: true) } it 'return REST code 200', :show_in_doc do @@ -61,8 +61,8 @@ describe API::V1::DossiersController do context 'when there are multiple pages' do let(:retour) { get :index, params: {token: admin.api_token, procedure_id: procedure_id, page: 2} } - let!(:dossier1) { create(:dossier, :with_entreprise, procedure: procedure, state: 'initiated') } - let!(:dossier2) { create(:dossier, :with_entreprise, procedure: procedure, state: 'initiated') } + let!(:dossier1) { create(:dossier, :with_entreprise, procedure: procedure, state: 'en_construction') } + let!(:dossier2) { create(:dossier, :with_entreprise, procedure: procedure, state: 'en_construction') } before do allow(Dossier).to receive(:per_page).and_return(1) diff --git a/spec/controllers/backoffice/commentaires_controller_spec.rb b/spec/controllers/backoffice/commentaires_controller_spec.rb index 284e8c2e9..a5b448bc3 100644 --- a/spec/controllers/backoffice/commentaires_controller_spec.rb +++ b/spec/controllers/backoffice/commentaires_controller_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe Backoffice::CommentairesController, type: :controller do - let(:dossier) { create(:dossier, :initiated) } + let(:dossier) { create(:dossier, :en_construction) } let(:dossier_id) { dossier.id } let(:email_commentaire) { 'test@test.com' } let(:texte_commentaire) { 'Commentaire de test' } @@ -89,10 +89,10 @@ describe Backoffice::CommentairesController, type: :controller do describe 'change dossier state after post a comment' do context 'gestionnaire is connected' do - context 'when dossier is at state initiated' do + context 'when dossier is at state en_construction' do before do sign_in gestionnaire - dossier.initiated! + dossier.en_construction! post :create, params: {dossier_id: dossier_id, texte_commentaire: texte_commentaire} dossier.reload diff --git a/spec/controllers/backoffice/dossiers/procedure_controller_spec.rb b/spec/controllers/backoffice/dossiers/procedure_controller_spec.rb index 6c1da0b3e..03d4c234e 100644 --- a/spec/controllers/backoffice/dossiers/procedure_controller_spec.rb +++ b/spec/controllers/backoffice/dossiers/procedure_controller_spec.rb @@ -4,7 +4,7 @@ describe Backoffice::Dossiers::ProcedureController, type: :controller do let(:gestionnaire) { create :gestionnaire } let(:procedure) { create :procedure, :published } let(:archived) { false } - let(:dossier) { create :dossier, procedure: procedure, archived: archived, state: 'initiated'} + let(:dossier) { create :dossier, procedure: procedure, archived: archived, state: 'en_construction'} before do create :assign_to, gestionnaire: gestionnaire, procedure: procedure diff --git a/spec/controllers/backoffice/dossiers_controller_spec.rb b/spec/controllers/backoffice/dossiers_controller_spec.rb index d5837a5ae..774c49943 100644 --- a/spec/controllers/backoffice/dossiers_controller_spec.rb +++ b/spec/controllers/backoffice/dossiers_controller_spec.rb @@ -7,8 +7,8 @@ describe Backoffice::DossiersController, type: :controller do let(:procedure) { create :procedure, :published } let(:procedure2) { create :procedure, :published } - let(:dossier) { create(:dossier, :with_entreprise, procedure: procedure, state: :initiated) } - let(:dossier2) { create(:dossier, :with_entreprise, procedure: procedure2, state: :initiated) } + let(:dossier) { create(:dossier, :with_entreprise, procedure: procedure, state: :en_construction) } + let(:dossier2) { create(:dossier, :with_entreprise, procedure: procedure2, state: :en_construction) } let(:dossier_archived) { create(:dossier, :with_entreprise, archived: true) } let(:dossier_id) { dossier.id } @@ -222,7 +222,7 @@ describe Backoffice::DossiersController, type: :controller do describe 'POST #receive' do before do - dossier.initiated! + dossier.en_construction! sign_in gestionnaire post :receive, params: { dossier_id: dossier_id } dossier.reload @@ -360,11 +360,11 @@ describe Backoffice::DossiersController, type: :controller do subject { post :reopen, params: {dossier_id: dossier_id} } - it 'change state to initiated' do + it 'change state to en_construction' do subject dossier.reload - expect(dossier.state).to eq('initiated') + expect(dossier.state).to eq('en_construction') end it { is_expected.to redirect_to backoffice_dossier_path(id: dossier_id) } diff --git a/spec/controllers/backoffice/private_formulaires_controller_spec.rb b/spec/controllers/backoffice/private_formulaires_controller_spec.rb index 65e44d8ec..838791fc5 100644 --- a/spec/controllers/backoffice/private_formulaires_controller_spec.rb +++ b/spec/controllers/backoffice/private_formulaires_controller_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe Backoffice::PrivateFormulairesController, type: :controller do let(:gestionnaire) { create :gestionnaire } - let(:dossier) { create :dossier, state: :initiated } + let(:dossier) { create :dossier, state: :en_construction } let(:dossier_champs_first) { 'plop' } before do diff --git a/spec/controllers/invites_controller_spec.rb b/spec/controllers/invites_controller_spec.rb index c2c0441b9..29e6f6853 100644 --- a/spec/controllers/invites_controller_spec.rb +++ b/spec/controllers/invites_controller_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe InvitesController, type: :controller do - let(:dossier) { create(:dossier, :initiated) } + let(:dossier) { create(:dossier, :en_construction) } let(:email) { 'plop@octo.com' } describe '#POST create' do diff --git a/spec/controllers/new_gestionnaire/avis_controller_spec.rb b/spec/controllers/new_gestionnaire/avis_controller_spec.rb index 71fc195e8..de5f3a367 100644 --- a/spec/controllers/new_gestionnaire/avis_controller_spec.rb +++ b/spec/controllers/new_gestionnaire/avis_controller_spec.rb @@ -6,7 +6,7 @@ describe NewGestionnaire::AvisController, type: :controller do let(:claimant) { create(:gestionnaire) } let(:gestionnaire) { create(:gestionnaire) } let(:procedure) { create(:procedure, :published, gestionnaires: [gestionnaire]) } - let(:dossier) { create(:dossier, :initiated, procedure: procedure) } + let(:dossier) { create(:dossier, :en_construction, procedure: procedure) } let!(:avis_without_answer) { Avis.create(dossier: dossier, claimant: claimant, gestionnaire: gestionnaire) } let!(:avis_with_answer) { Avis.create(dossier: dossier, claimant: claimant, gestionnaire: gestionnaire, answer: 'yop') } diff --git a/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb b/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb index d734b5c57..faf46d920 100644 --- a/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb +++ b/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb @@ -5,16 +5,16 @@ describe NewGestionnaire::DossiersController, type: :controller do let(:gestionnaire) { create(:gestionnaire) } let(:procedure) { create(:procedure, :published, gestionnaires: [gestionnaire]) } - let(:dossier) { create(:dossier, :initiated, procedure: procedure) } + let(:dossier) { create(:dossier, :en_construction, procedure: procedure) } before { sign_in(gestionnaire) } describe '#attestation' do context 'when a dossier has an attestation' do let(:fake_pdf) { double(read: 'pdf content') } - let!(:dossier) { create(:dossier, :initiated, attestation: Attestation.new, procedure: procedure) } + let!(:dossier) { create(:dossier, :en_construction, attestation: Attestation.new, procedure: procedure) } let!(:procedure) { create(:procedure, :published, gestionnaires: [gestionnaire]) } - let!(:dossier) { create(:dossier, :initiated, attestation: Attestation.new, procedure: procedure) } + let!(:dossier) { create(:dossier, :en_construction, attestation: Attestation.new, procedure: procedure) } it 'returns the attestation pdf' do allow_any_instance_of(Attestation).to receive(:pdf).and_return(fake_pdf) @@ -79,7 +79,7 @@ describe NewGestionnaire::DossiersController, type: :controller do describe '#passer_en_instruction' do before do - dossier.initiated! + dossier.en_construction! sign_in gestionnaire post :passer_en_instruction, params: { procedure_id: procedure.id, dossier_id: dossier.id } dossier.reload @@ -98,11 +98,11 @@ describe NewGestionnaire::DossiersController, type: :controller do subject { post :repasser_en_construction, params: { procedure_id: procedure.id, dossier_id: dossier.id} } - it 'change state to initiated' do + it 'change state to en_construction' do subject dossier.reload - expect(dossier.state).to eq('initiated') + expect(dossier.state).to eq('en_construction') end it { is_expected.to redirect_to dossier_path(procedure, dossier) } @@ -344,7 +344,7 @@ describe NewGestionnaire::DossiersController, type: :controller do end let(:dossier) do - create(:dossier, :initiated, procedure: procedure, champs_private: [champ_multiple_drop_down_list, champ_datetime]) + create(:dossier, :en_construction, procedure: procedure, champs_private: [champ_multiple_drop_down_list, champ_datetime]) end before do diff --git a/spec/controllers/new_gestionnaire/procedures_controller_spec.rb b/spec/controllers/new_gestionnaire/procedures_controller_spec.rb index a7f2f7583..8f9e6c530 100644 --- a/spec/controllers/new_gestionnaire/procedures_controller_spec.rb +++ b/spec/controllers/new_gestionnaire/procedures_controller_spec.rb @@ -134,15 +134,15 @@ describe NewGestionnaire::ProceduresController, type: :controller do context "with not draft state on multiple procedures" do let(:procedure2) { create(:procedure, :published) } - let(:state) { "initiated" } + let(:state) { "en_construction" } before do - create(:dossier, procedure: procedure, state: "initiated") + create(:dossier, procedure: procedure, state: "en_construction") create(:dossier, procedure: procedure, state: "received") create(:dossier, procedure: procedure, state: "without_continuation", archived: true) gestionnaire.procedures << procedure2 - create(:dossier, :followed, procedure: procedure2, state: "initiated") + create(:dossier, :followed, procedure: procedure2, state: "en_construction") create(:dossier, procedure: procedure2, state: "closed") gestionnaire.followed_dossiers << create(:dossier, procedure: procedure2, state: "received") diff --git a/spec/controllers/new_gestionnaire/recherche_controller_spec.rb b/spec/controllers/new_gestionnaire/recherche_controller_spec.rb index 179226a93..7e4a67039 100644 --- a/spec/controllers/new_gestionnaire/recherche_controller_spec.rb +++ b/spec/controllers/new_gestionnaire/recherche_controller_spec.rb @@ -1,8 +1,8 @@ require 'spec_helper' describe NewGestionnaire::RechercheController, type: :controller do - let(:dossier) { create(:dossier, :initiated) } - let(:dossier2) { create(:dossier, :initiated, procedure: dossier.procedure) } + let(:dossier) { create(:dossier, :en_construction) } + let(:dossier2) { create(:dossier, :en_construction, procedure: dossier.procedure) } let(:gestionnaire) { create(:gestionnaire) } before { gestionnaire.procedures << dossier2.procedure } @@ -26,7 +26,7 @@ describe NewGestionnaire::RechercheController, type: :controller do end context 'when gestionnaire do not own the dossier' do - let(:dossier3) { create(:dossier, :initiated) } + let(:dossier3) { create(:dossier, :en_construction) } let(:query) { dossier3.id } it { is_expected.to have_http_status(200) } diff --git a/spec/controllers/stats_controller_spec.rb b/spec/controllers/stats_controller_spec.rb index 2daffb052..d09c85432 100644 --- a/spec/controllers/stats_controller_spec.rb +++ b/spec/controllers/stats_controller_spec.rb @@ -141,21 +141,21 @@ describe StatsController, type: :controller do procedure_1 = FactoryGirl.create(:procedure) procedure_2 = FactoryGirl.create(:procedure) dossier_p1_a = FactoryGirl.create(:dossier, - :procedure => procedure_1, - :initiated_at => 2.months.ago.beginning_of_month, - :processed_at => 2.months.ago.beginning_of_month + 3.days) + :procedure => procedure_1, + :en_construction_at => 2.months.ago.beginning_of_month, + :processed_at => 2.months.ago.beginning_of_month + 3.days) dossier_p1_b = FactoryGirl.create(:dossier, - :procedure => procedure_1, - :initiated_at => 2.months.ago.beginning_of_month, - :processed_at => 2.months.ago.beginning_of_month + 1.days) + :procedure => procedure_1, + :en_construction_at => 2.months.ago.beginning_of_month, + :processed_at => 2.months.ago.beginning_of_month + 1.days) dossier_p1_c = FactoryGirl.create(:dossier, - :procedure => procedure_1, - :initiated_at => 1.months.ago.beginning_of_month, - :processed_at => 1.months.ago.beginning_of_month + 5.days) + :procedure => procedure_1, + :en_construction_at => 1.months.ago.beginning_of_month, + :processed_at => 1.months.ago.beginning_of_month + 5.days) dossier_p2_a = FactoryGirl.create(:dossier, - :procedure => procedure_2, - :initiated_at => 2.month.ago.beginning_of_month, - :processed_at => 2.month.ago.beginning_of_month + 4.days) + :procedure => procedure_2, + :en_construction_at => 2.month.ago.beginning_of_month, + :processed_at => 2.month.ago.beginning_of_month + 4.days) # Write directly in the DB to avoid the before_validation hook Dossier.update_all(state: "closed") @@ -191,22 +191,22 @@ describe StatsController, type: :controller do dossier_p1_a = FactoryGirl.create(:dossier, :procedure => procedure_1, :created_at => 2.months.ago.beginning_of_month, - :initiated_at => 2.months.ago.beginning_of_month + 30.minutes, + :en_construction_at => 2.months.ago.beginning_of_month + 30.minutes, :processed_at => 2.months.ago.beginning_of_month + 1.day) dossier_p1_b = FactoryGirl.create(:dossier, :procedure => procedure_1, :created_at => 2.months.ago.beginning_of_month, - :initiated_at => 2.months.ago.beginning_of_month + 10.minutes, + :en_construction_at => 2.months.ago.beginning_of_month + 10.minutes, :processed_at => 2.months.ago.beginning_of_month + 1.day) dossier_p1_c = FactoryGirl.create(:dossier, :procedure => procedure_1, :created_at => 1.months.ago.beginning_of_month, - :initiated_at => 1.months.ago.beginning_of_month + 50.minutes, + :en_construction_at => 1.months.ago.beginning_of_month + 50.minutes, :processed_at => 1.months.ago.beginning_of_month + 1.day) dossier_p2_a = FactoryGirl.create(:dossier, :procedure => procedure_2, :created_at => 2.month.ago.beginning_of_month, - :initiated_at => 2.month.ago.beginning_of_month + 80.minutes, + :en_construction_at => 2.month.ago.beginning_of_month + 80.minutes, :processed_at => 2.month.ago.beginning_of_month + 1.day) # Write directly in the DB to avoid the before_validation hook diff --git a/spec/controllers/users/carte_controller_shared_example.rb b/spec/controllers/users/carte_controller_shared_example.rb index dff16acca..143772ddc 100644 --- a/spec/controllers/users/carte_controller_shared_example.rb +++ b/spec/controllers/users/carte_controller_shared_example.rb @@ -67,7 +67,7 @@ shared_examples 'carte_controller_spec' do end context 'En train de modifier la localisation' do - let(:dossier) { create(:dossier, state: 'initiated') } + let(:dossier) { create(:dossier, state: 'en_construction') } before do post :save, params: {dossier_id: dossier.id, json_latlngs: ''} end diff --git a/spec/controllers/users/description_controller_shared_example.rb b/spec/controllers/users/description_controller_shared_example.rb index 90d101cef..2b4ba577c 100644 --- a/spec/controllers/users/description_controller_shared_example.rb +++ b/spec/controllers/users/description_controller_shared_example.rb @@ -125,7 +125,7 @@ shared_examples 'description_controller_spec' do end it 'etat du dossier est soumis' do - expect(dossier.state).to eq('initiated') + expect(dossier.state).to eq('en_construction') end context 'when user whould like save just a draft' do @@ -143,7 +143,7 @@ shared_examples 'description_controller_spec' do context 'En train de manipuler un dossier non brouillon' do before do - dossier.initiated! + dossier.en_construction! post :update, params: {dossier_id: dossier_id} dossier.reload end diff --git a/spec/controllers/users/description_controller_spec.rb b/spec/controllers/users/description_controller_spec.rb index 12f0dfa6f..4421f1f35 100644 --- a/spec/controllers/users/description_controller_spec.rb +++ b/spec/controllers/users/description_controller_spec.rb @@ -6,7 +6,7 @@ describe Users::DescriptionController, type: :controller, vcr: {cassette_name: ' let(:owner_user) { create(:user) } let(:invite_by_user) { create :user, email: 'invite@plop.com' } let(:archived_at) { nil } - let(:state) { 'initiated' } + let(:state) { 'en_construction' } let(:procedure) { create(:procedure, :with_two_type_de_piece_justificative, :with_type_de_champ, :with_datetime, cerfa_flag: true, published_at: Time.now, archived_at: archived_at) } let(:dossier) { create(:dossier, procedure: procedure, user: owner_user, state: state) } diff --git a/spec/controllers/users/dossiers_controller_spec.rb b/spec/controllers/users/dossiers_controller_spec.rb index 1b9469517..b5c45e12a 100644 --- a/spec/controllers/users/dossiers_controller_spec.rb +++ b/spec/controllers/users/dossiers_controller_spec.rb @@ -435,7 +435,7 @@ 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: "initiated", user: user } + let!(:dossier_not_draft) { create :dossier, state: "en_construction", user: user } subject { delete :destroy, params: {id: dossier.id} } diff --git a/spec/controllers/users/recapitulatif_controller_spec.rb b/spec/controllers/users/recapitulatif_controller_spec.rb index 120e2e344..d4ee814a9 100644 --- a/spec/controllers/users/recapitulatif_controller_spec.rb +++ b/spec/controllers/users/recapitulatif_controller_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe Users::RecapitulatifController, type: :controller do - let(:dossier) { create(:dossier, state: 'initiated') } + let(:dossier) { create(:dossier, state: 'en_construction') } let(:bad_dossier_id) { Dossier.count + 100000 } before do @@ -43,10 +43,10 @@ describe Users::RecapitulatifController, type: :controller do it 'dossier change his state for closed' do dossier.reload - expect(dossier.state).to eq('initiated') + expect(dossier.state).to eq('en_construction') end - it 'a message informe user what his dossier is initiated' do + it 'a message informe user what his dossier is en_construction' do expect(flash[:notice]).to include('Dossier soumis avec succès.') end end diff --git a/spec/decorators/dossier_decorator_spec.rb b/spec/decorators/dossier_decorator_spec.rb index cf35f4662..64ac28aa8 100644 --- a/spec/decorators/dossier_decorator_spec.rb +++ b/spec/decorators/dossier_decorator_spec.rb @@ -27,8 +27,8 @@ describe DossierDecorator do expect(subject).to eq('Brouillon') end - it 'initiated is initiate' do - dossier.initiated! + it 'en_construction is En construction' do + dossier.en_construction! expect(subject).to eq('En construction') end @@ -74,7 +74,7 @@ describe DossierDecorator do context "when the dossier is not in brouillon state" do before do - dossier.state = 'initiated' + dossier.state = 'en_construction' dossier.save end diff --git a/spec/facades/admin_procedures_show_facades_spec.rb b/spec/facades/admin_procedures_show_facades_spec.rb index 5e1641aca..c1cf99841 100644 --- a/spec/facades/admin_procedures_show_facades_spec.rb +++ b/spec/facades/admin_procedures_show_facades_spec.rb @@ -4,9 +4,9 @@ describe AdminProceduresShowFacades do let!(:procedure) { create(:procedure) } let!(:dossier_0) { create(:dossier, procedure: procedure, state: 'draft') } - let!(:dossier_1) { create(:dossier, procedure: procedure, state: 'initiated') } - let!(:dossier_2) { create(:dossier, procedure: procedure, state: 'initiated') } - let!(:dossier_6) { create(:dossier, procedure: procedure, archived: true, state: 'initiated') } + 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') } subject { AdminProceduresShowFacades.new procedure } @@ -33,7 +33,7 @@ describe AdminProceduresShowFacades do it { expect(subject.size).to eq(1) } - it { expect(subject.first.state).to eq('initiated') } + it { expect(subject.first.state).to eq('en_construction') } it { expect(subject.first.total).to eq(1) } end diff --git a/spec/factories/dossier.rb b/spec/factories/dossier.rb index 924696a81..afab7d294 100644 --- a/spec/factories/dossier.rb +++ b/spec/factories/dossier.rb @@ -72,10 +72,10 @@ FactoryGirl.define do end end - trait :initiated do + trait :en_construction do after(:create) do |dossier, _evaluator| - dossier.state = 'initiated' - dossier.initiated_at = dossier.created_at + 1.minute + dossier.state = 'en_construction' + dossier.en_construction_at = dossier.created_at + 1.minute dossier.save! end end @@ -83,7 +83,7 @@ FactoryGirl.define do trait :received do after(:create) do |dossier, _evaluator| dossier.state = 'received' - dossier.initiated_at = dossier.created_at + 1.minute + dossier.en_construction_at = dossier.created_at + 1.minute dossier.created_at = dossier.created_at + 2.minute dossier.save! end diff --git a/spec/features/backoffice/add_commentaire_spec.rb b/spec/features/backoffice/add_commentaire_spec.rb index 7bc6d1769..8ae6b1f97 100644 --- a/spec/features/backoffice/add_commentaire_spec.rb +++ b/spec/features/backoffice/add_commentaire_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' feature 'add commentaire on backoffice' do let(:procedure) { create(:procedure, :published) } - let(:dossier) { create(:dossier, :with_entreprise, procedure: procedure, state: 'initiated') } + let(:dossier) { create(:dossier, :with_entreprise, procedure: procedure, state: 'en_construction') } let(:dossier_id) { dossier.id } let!(:commentaire) { create(:commentaire, dossier: dossier, email: 'toto@toto.com') } let(:email_commentaire) { 'test@test.com' } diff --git a/spec/features/backoffice/flux_de_commentaires_spec.rb b/spec/features/backoffice/flux_de_commentaires_spec.rb index 8ff622b4d..e841e9f4e 100644 --- a/spec/features/backoffice/flux_de_commentaires_spec.rb +++ b/spec/features/backoffice/flux_de_commentaires_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' feature 'backoffice: flux de commentaires' do let(:procedure) { create(:procedure, :published) } let(:gestionnaire) { create(:gestionnaire) } - let(:dossier) { create(:dossier, :with_entreprise, procedure: procedure, state: 'initiated') } + let(:dossier) { create(:dossier, :with_entreprise, procedure: procedure, state: 'en_construction') } let(:dossier_id) { dossier.id } let(:champ1) { create(:champ, dossier: dossier, type_de_champ: create(:type_de_champ_public, libelle: "subtitle1")) } diff --git a/spec/features/backoffice/index_show_procedure_spec.rb b/spec/features/backoffice/index_show_procedure_spec.rb index fc6e60d47..beabf0c4c 100644 --- a/spec/features/backoffice/index_show_procedure_spec.rb +++ b/spec/features/backoffice/index_show_procedure_spec.rb @@ -10,7 +10,7 @@ feature 'As an Accompagnateur I can navigate and use each functionnality around create :assign_to, gestionnaire: gestionnaire, procedure: procedure_1 create :assign_to, gestionnaire: gestionnaire, procedure: procedure_2 30.times do - Dossier.create(procedure_id: procedure_1.id.to_s, user: user, state: 'initiated') + Dossier.create(procedure_id: procedure_1.id.to_s, user: user, state: 'en_construction') end 22.times do Dossier.create(procedure_id: procedure_2.id.to_s, user: user, state: 'received') diff --git a/spec/features/backoffice/lateral_page_pref_list_dossier_backoffice_spec.rb b/spec/features/backoffice/lateral_page_pref_list_dossier_backoffice_spec.rb index 7e7f57772..21349de5b 100644 --- a/spec/features/backoffice/lateral_page_pref_list_dossier_backoffice_spec.rb +++ b/spec/features/backoffice/lateral_page_pref_list_dossier_backoffice_spec.rb @@ -6,7 +6,7 @@ feature 'usage of pref list dossier lateral panel', js: true do let(:procedure) { create(:procedure, :published, administrateur: administrateur) } before do - create(:dossier, :with_entreprise, procedure: procedure, state: 'initiated') + create(:dossier, :with_entreprise, procedure: procedure, state: 'en_construction') create :assign_to, procedure: procedure, gestionnaire: gestionnaire login_as gestionnaire, scope: :gestionnaire diff --git a/spec/features/backoffice/lateral_page_pref_list_dossier_by_procedure_backoffice_spec.rb b/spec/features/backoffice/lateral_page_pref_list_dossier_by_procedure_backoffice_spec.rb index 9b9dd4432..784d41413 100644 --- a/spec/features/backoffice/lateral_page_pref_list_dossier_by_procedure_backoffice_spec.rb +++ b/spec/features/backoffice/lateral_page_pref_list_dossier_by_procedure_backoffice_spec.rb @@ -6,7 +6,7 @@ feature 'usage of pref list dossier lateral panel by procedure', js: true do let(:procedure) { create(:procedure, :published, :with_type_de_champ, administrateur: administrateur) } before do - create(:dossier, :with_entreprise, procedure: procedure, state: 'initiated') + create(:dossier, :with_entreprise, procedure: procedure, state: 'en_construction') create :assign_to, procedure: procedure, gestionnaire: gestionnaire login_as gestionnaire, scope: :gestionnaire diff --git a/spec/features/backoffice/navigate_to_dossier_spec.rb b/spec/features/backoffice/navigate_to_dossier_spec.rb index f2e80f9f2..a24295699 100644 --- a/spec/features/backoffice/navigate_to_dossier_spec.rb +++ b/spec/features/backoffice/navigate_to_dossier_spec.rb @@ -6,8 +6,8 @@ feature 'on backoffice page', js: true do let(:procedure) { create(:procedure, :published, administrateur: administrateur) } let(:procedure_individual) { create :procedure, :published, libelle: 'procedure individual', administrateur: administrateur, for_individual: true } - let!(:dossier) { create(:dossier, :with_entreprise, procedure: procedure, state: 'initiated') } - let!(:dossier_individual) { create :dossier, procedure: procedure_individual, state: 'initiated' } + let!(:dossier) { create(:dossier, :with_entreprise, procedure: procedure, state: 'en_construction') } + let!(:dossier_individual) { create :dossier, procedure: procedure_individual, state: 'en_construction' } before do create :assign_to, gestionnaire: gestionnaire, procedure: procedure @@ -34,7 +34,7 @@ feature 'on backoffice page', js: true do end context "and goes to the page of a dossier he hasn't access to" do - let!(:unauthorized_dossier) { create(:dossier, :with_entreprise, state: 'initiated') } + let!(:unauthorized_dossier) { create(:dossier, :with_entreprise, state: 'en_construction') } before do visit backoffice_dossier_path(unauthorized_dossier) diff --git a/spec/features/backoffice/search_file_spec.rb b/spec/features/backoffice/search_file_spec.rb index d284671cd..c8a0fbc10 100644 --- a/spec/features/backoffice/search_file_spec.rb +++ b/spec/features/backoffice/search_file_spec.rb @@ -39,8 +39,8 @@ feature 'search file on gestionnaire backoffice' do end context 'when terms input does return result' do - let!(:dossier) { create(:dossier, :with_entreprise, procedure: procedure, state: 'initiated') } - let!(:dossier_2) { create(:dossier, procedure: procedure, state: 'initiated') } + let!(:dossier) { create(:dossier, :with_entreprise, procedure: procedure, state: 'en_construction') } + let!(:dossier_2) { create(:dossier, procedure: procedure, state: 'en_construction') } let(:terms) { dossier.entreprise.raison_sociale } diff --git a/spec/features/new_gestionnaire/gestionnaire_spec.rb b/spec/features/new_gestionnaire/gestionnaire_spec.rb index 15acf9e38..a03a9e7c5 100644 --- a/spec/features/new_gestionnaire/gestionnaire_spec.rb +++ b/spec/features/new_gestionnaire/gestionnaire_spec.rb @@ -5,7 +5,7 @@ feature 'The gestionnaire part' do let!(:gestionnaire) { create(:gestionnaire, password: password) } let!(:procedure) { create(:procedure, :published, gestionnaires: [gestionnaire]) } - let!(:dossier) { create(:dossier, state: :initiated, procedure: procedure) } + let!(:dossier) { create(:dossier, state: :en_construction, procedure: procedure) } scenario 'A gestionnaire can accept a dossier' do log_in(gestionnaire.email, password) diff --git a/spec/features/users/dossier_edition_spec.rb b/spec/features/users/dossier_edition_spec.rb index 698cb0dd8..dd9f47aad 100644 --- a/spec/features/users/dossier_edition_spec.rb +++ b/spec/features/users/dossier_edition_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' feature 'As a User I want to edit a dossier I own' do let(:user) { create(:user) } let(:procedure_for_individual) { create(:procedure, :published, :for_individual, :with_type_de_champ, :with_two_type_de_piece_justificative, :with_dossier_link) } - let!(:dossier) { create(:dossier, :with_entreprise, :for_individual, :with_dossier_link, procedure: procedure_for_individual, user: user, autorisation_donnees: true, state: 'initiated') } + let!(:dossier) { create(:dossier, :with_entreprise, :for_individual, :with_dossier_link, procedure: procedure_for_individual, user: user, autorisation_donnees: true, state: 'en_construction') } before "Create dossier and visit root path" do login_as user, scope: :user diff --git a/spec/features/users/dossier_index_spec.rb b/spec/features/users/dossier_index_spec.rb index dc696a9ad..7365366af 100644 --- a/spec/features/users/dossier_index_spec.rb +++ b/spec/features/users/dossier_index_spec.rb @@ -14,7 +14,7 @@ feature 'As a User I want to sort and paginate dossiers', js: true do page.find_by_id('etape_suivante').trigger('click') page.find_by_id('suivant').trigger('click') 50.times do - Dossier.create(procedure_id: procedure_for_individual.id, user_id: user.id, state: "initiated") + Dossier.create(procedure_id: procedure_for_individual.id, user_id: user.id, state: "en_construction") end visit root_path end diff --git a/spec/features/users/flux_de_commentaires_spec.rb b/spec/features/users/flux_de_commentaires_spec.rb index 734db0d78..b39c5717e 100644 --- a/spec/features/users/flux_de_commentaires_spec.rb +++ b/spec/features/users/flux_de_commentaires_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' feature 'users: flux de commentaires' do let(:user) { create(:user) } - let(:dossier) { create(:dossier, :with_entreprise, user: user, state: "initiated") } + let(:dossier) { create(:dossier, :with_entreprise, user: user, state: "en_construction") } let(:dossier_id) { dossier.id } let(:champ1) { dossier.champs.first } diff --git a/spec/features/users/list_dossiers_spec.rb b/spec/features/users/list_dossiers_spec.rb index 64a55d0b2..edd93ec63 100644 --- a/spec/features/users/list_dossiers_spec.rb +++ b/spec/features/users/list_dossiers_spec.rb @@ -2,10 +2,10 @@ require 'spec_helper' describe 'user access to the list of his dossier' do let(:user) { create(:user) } - let!(:last_updated_dossier) { create(:dossier, :with_entreprise, user: user, state: 'initiated')} - let!(:dossier1) { create(:dossier, :with_entreprise, user: user, state: 'initiated') } + let!(:last_updated_dossier) { create(:dossier, :with_entreprise, user: user, state: 'en_construction')} + let!(:dossier1) { create(:dossier, :with_entreprise, user: user, state: 'en_construction') } let!(:dossier2) { create(:dossier, :with_entreprise) } - let!(:dossier_archived) { create(:dossier, :with_entreprise, user: user, state: 'initiated') } + let!(:dossier_archived) { create(:dossier, :with_entreprise, user: user, state: 'en_construction') } before do last_updated_dossier.update_column(:updated_at, "19/07/2052 15:35".to_time) diff --git a/spec/features/users/onglets_link_spec.rb b/spec/features/users/onglets_link_spec.rb index 5c9232c86..694a2030a 100644 --- a/spec/features/users/onglets_link_spec.rb +++ b/spec/features/users/onglets_link_spec.rb @@ -3,10 +3,10 @@ require 'spec_helper' feature 'on click on tabs button' do let(:user) { create :user } - let(:dossier_invite) { create(:dossier, :with_entreprise, user: create(:user), state: 'initiated') } + let(:dossier_invite) { create(:dossier, :with_entreprise, user: create(:user), state: 'en_construction') } before do - create(:dossier, :with_entreprise, user: user, state: 'initiated') + create(:dossier, :with_entreprise, user: user, state: 'en_construction') create(:dossier, :with_entreprise, user: user, state: 'received') create(:dossier, :with_entreprise, user: user, state: 'closed') create(:dossier, :with_entreprise, user: user, state: 'refused') diff --git a/spec/jobs/auto_archive_procedure_job_spec.rb b/spec/jobs/auto_archive_procedure_job_spec.rb index cf4c62150..d4b0102d6 100644 --- a/spec/jobs/auto_archive_procedure_job_spec.rb +++ b/spec/jobs/auto_archive_procedure_job_spec.rb @@ -19,14 +19,14 @@ RSpec.describe AutoArchiveProcedureJob, type: :job do 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!(:dossier2) { create(:dossier, procedure: procedure_hier, state: 'initiated', archived: false)} - let!(:dossier3) { create(:dossier, procedure: procedure_hier, state: 'initiated', archived: false)} - let!(:dossier4) { create(:dossier, procedure: procedure_hier, state: 'initiated', 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)} let!(:dossier5) { create(:dossier, procedure: procedure_hier, state: 'received', archived: false)} let!(:dossier6) { create(:dossier, procedure: procedure_hier, state: 'closed', archived: false)} let!(:dossier7) { create(:dossier, procedure: procedure_hier, state: 'refused', archived: false)} let!(:dossier8) { create(:dossier, procedure: procedure_hier, state: 'without_continuation', archived: false)} - let!(:dossier9) { create(:dossier, procedure: procedure_aujourdhui, state: 'initiated', archived: false)} + let!(:dossier9) { create(:dossier, procedure: procedure_aujourdhui, state: 'en_construction', archived: false)} before do subject 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 0c20ce31c..bfee9e2e7 100644 --- a/spec/jobs/auto_receive_dossiers_for_procedure_job_spec.rb +++ b/spec/jobs/auto_receive_dossiers_for_procedure_job_spec.rb @@ -10,8 +10,8 @@ RSpec.describe AutoReceiveDossiersForProcedureJob, type: :job do subject { AutoReceiveDossiersForProcedureJob.new.perform(procedure_id, 'received') } context "with some dossiers" do - let(:nouveau_dossier1) { create(:dossier, :initiated) } - let(:nouveau_dossier2) { create(:dossier, :initiated, procedure: nouveau_dossier1.procedure) } + 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 } diff --git a/spec/models/dossier_spec.rb b/spec/models/dossier_spec.rb index 047ff9671..b4c215b04 100644 --- a/spec/models/dossier_spec.rb +++ b/spec/models/dossier_spec.rb @@ -112,7 +112,7 @@ describe Dossier do it 'does not create default champs' do expect(subject).not_to receive(:build_default_champs) - subject.update_attributes(state: 'initiated') + subject.update_attributes(state: 'en_construction') end end end @@ -157,14 +157,14 @@ describe Dossier do context 'when he initiate a dossier' do let(:action) { 'initiate' } - it { is_expected.to eq('initiated') } + it { is_expected.to eq('en_construction') } end end end - context 'when dossier is at state initiated' do + context 'when dossier is at state en_construction' do before do - dossier.initiated! + dossier.en_construction! end context 'when user is connect' do @@ -173,13 +173,13 @@ describe Dossier do context 'when is update dossier informations' do let(:action) { 'update' } - it { is_expected.to eq('initiated') } + it { is_expected.to eq('en_construction') } end context 'when is post a comment' do let(:action) { 'comment' } - it { is_expected.to eq('initiated') } + it { is_expected.to eq('en_construction') } end end @@ -189,13 +189,13 @@ describe Dossier do context 'when is post a comment' do let(:action) { 'comment' } - it { is_expected.to eq('initiated') } + it { is_expected.to eq('en_construction') } end context 'when is follow' do let(:action) { 'follow' } - it { is_expected.to eq 'initiated' } + it { is_expected.to eq 'en_construction' } end end end @@ -394,7 +394,7 @@ describe Dossier do let(:date1) { 1.day.ago } let(:date2) { 1.hour.ago } let(:date3) { 1.minute.ago } - let(:dossier) { create(:dossier, :with_entreprise, user: user, procedure: procedure, initiated_at: date1, received_at: date2, processed_at: date3, motivation: "Motivation") } + let(:dossier) { create(:dossier, :with_entreprise, user: user, procedure: procedure, en_construction_at: date1, received_at: date2, processed_at: date3, motivation: "Motivation") } let!(:follow) { create(:follow, gestionnaire: gestionnaire, dossier: dossier) } describe '#export_headers' do @@ -460,7 +460,7 @@ describe Dossier do dossier.user.email, "false", "draft", - dossier.initiated_at, + dossier.en_construction_at, dossier.received_at, dossier.processed_at, "Motivation", @@ -615,15 +615,15 @@ describe Dossier do describe "#text_summary" do let(:procedure) { create(:procedure, libelle: "Procédure", organisation: "Organisme") } - context 'when the dossier has been initiated' do - let(:dossier) { create :dossier, procedure: procedure, state: 'initiated', initiated_at: "31/12/2010".to_date } + context 'when the dossier has been en_construction' do + let(:dossier) { create :dossier, procedure: procedure, state: 'en_construction', en_construction_at: "31/12/2010".to_date } subject { dossier.text_summary } it { is_expected.to eq("Dossier déposé le 31/12/2010 sur la procédure Procédure gérée par l'organisme Organisme") } end - context 'when the dossier has not been initiated' do + context 'when the dossier has not been en_construction' do let(:dossier) { create :dossier, procedure: procedure, state: 'draft' } subject { dossier.text_summary } @@ -634,7 +634,7 @@ describe Dossier do describe '#avis_for' do let!(:procedure) { create(:procedure, :published) } - let!(:dossier) { create(:dossier, procedure: procedure, state: :initiated) } + let!(:dossier) { create(:dossier, procedure: procedure, state: :en_construction) } let!(:gestionnaire) { create(:gestionnaire, procedures: [procedure]) } let!(:expert_1) { create(:gestionnaire) } @@ -691,26 +691,26 @@ describe Dossier do Timecop.freeze(beginning_of_day) end - context 'when dossier is initiated' do + context 'when dossier is en_construction' do before do - dossier.initiated! + dossier.en_construction! dossier.reload end - it { expect(dossier.state).to eq('initiated') } - it { expect(dossier.initiated_at).to eq(beginning_of_day) } + it { expect(dossier.state).to eq('en_construction') } + it { expect(dossier.en_construction_at).to eq(beginning_of_day) } - it 'should keep first initiated_at date' do + it 'should keep first en_construction_at date' do Timecop.return dossier.received! - dossier.initiated! + dossier.en_construction! - expect(dossier.initiated_at).to eq(beginning_of_day) + expect(dossier.en_construction_at).to eq(beginning_of_day) end end context 'when dossier is received' do - let(:state) { 'initiated' } + let(:state) { 'en_construction' } before do dossier.received! @@ -720,9 +720,9 @@ describe Dossier do it { expect(dossier.state).to eq('received') } it { expect(dossier.received_at).to eq(beginning_of_day) } - it 'should keep first received_at date if dossier is set to initiated again' do + it 'should keep first received_at date if dossier is set to en_construction again' do Timecop.return - dossier.initiated! + dossier.en_construction! dossier.received! expect(dossier.received_at).to eq(beginning_of_day) @@ -761,9 +761,9 @@ describe Dossier do describe '.downloadable_sorted' do let(:procedure) { create(:procedure) } let!(:dossier) { create(:dossier, :with_entreprise, procedure: procedure, state: :draft) } - let!(:dossier2) { create(:dossier, :with_entreprise, procedure: procedure, state: :initiated, initiated_at: DateTime.parse('03/01/2010')) } - let!(:dossier3) { create(:dossier, :with_entreprise, procedure: procedure, state: :received, initiated_at: DateTime.parse('01/01/2010')) } - let!(:dossier4) { create(:dossier, :with_entreprise, procedure: procedure, state: :received, archived: true, initiated_at: DateTime.parse('02/01/2010')) } + 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')) } subject { procedure.dossiers.downloadable_sorted } @@ -772,7 +772,7 @@ describe Dossier do describe "#send_dossier_received" do let(:procedure) { create(:procedure) } - let(:dossier) { create(:dossier, procedure: procedure, state: :initiated) } + let(:dossier) { create(:dossier, procedure: procedure, state: :en_construction) } before do allow(NotificationMailer).to receive(:send_dossier_received).and_return(double(deliver_later: nil)) @@ -805,7 +805,7 @@ describe Dossier do end it "does not send an email when the dossier is created with a non draft state" do - expect { Dossier.create(procedure: procedure, state: "initiated", user: user) }.not_to change(ActionMailer::Base.deliveries, :size) + 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) expect { Dossier.create(procedure: procedure, state: "refused", user: user) }.not_to change(ActionMailer::Base.deliveries, :size) diff --git a/spec/models/gestionnaire_spec.rb b/spec/models/gestionnaire_spec.rb index b15e8363b..892cf05da 100644 --- a/spec/models/gestionnaire_spec.rb +++ b/spec/models/gestionnaire_spec.rb @@ -169,7 +169,7 @@ describe Gestionnaire, type: :model do end context 'when gestionnaire follow a dossier with a notification into the procedure past in params' do - let(:dossier) { create(:dossier, procedure: procedure, state: 'initiated') } + let(:dossier) { create(:dossier, procedure: procedure, state: 'en_construction') } before do create :follow, gestionnaire: gestionnaire, dossier: dossier @@ -405,7 +405,7 @@ describe Gestionnaire, type: :model do end describe '#notifications_for_dossier' do - let!(:dossier) { create(:dossier, :followed, state: 'initiated') } + let!(:dossier) { create(:dossier, :followed, state: 'en_construction') } let(:gestionnaire) { dossier.follows.first.gestionnaire } subject { gestionnaire.notifications_for_dossier(dossier) } @@ -454,12 +454,12 @@ describe Gestionnaire, type: :model do end describe '#notification_for_procedure' do - let!(:dossier) { create(:dossier, :followed, state: 'initiated') } + let!(:dossier) { create(:dossier, :followed, state: 'en_construction') } let(:gestionnaire) { dossier.follows.first.gestionnaire } let(:procedure) { dossier.procedure } let!(:gestionnaire_2) { create(:gestionnaire, procedures: [procedure]) } - let!(:dossier_on_procedure_2) { create(:dossier, :followed, state: 'initiated') } + let!(:dossier_on_procedure_2) { create(:dossier, :followed, state: 'en_construction') } let!(:gestionnaire_on_procedure_2) { dossier_on_procedure_2.follows.first.gestionnaire } before do @@ -535,7 +535,7 @@ describe Gestionnaire, type: :model do end describe '#notifications_per_procedure' do - let!(:dossier) { create(:dossier, :followed, state: 'initiated') } + let!(:dossier) { create(:dossier, :followed, state: 'en_construction') } let(:gestionnaire) { dossier.follows.first.gestionnaire } let(:procedure) { dossier.procedure } @@ -549,7 +549,7 @@ describe Gestionnaire, type: :model do end describe '#mark_tab_as_seen' do - let!(:dossier) { create(:dossier, :followed, state: 'initiated') } + let!(:dossier) { create(:dossier, :followed, state: 'en_construction') } let(:gestionnaire) { dossier.follows.first.gestionnaire } let(:freeze_date) { DateTime.parse('12/12/2012') } diff --git a/spec/models/procedure_overview_spec.rb b/spec/models/procedure_overview_spec.rb index a6c55664f..87022be45 100644 --- a/spec/models/procedure_overview_spec.rb +++ b/spec/models/procedure_overview_spec.rb @@ -34,7 +34,7 @@ describe ProcedureOverview, type: :model do describe 'dossiers_en_construction_count' do let!(:dossier_en_construction) do - create(:dossier, procedure: procedure, state: :initiated, created_at: monday) + create(:dossier, procedure: procedure, state: :en_construction, created_at: monday) end it { expect(procedure_overview.dossiers_en_construction_count).to eq(1) } diff --git a/spec/models/procedure_spec.rb b/spec/models/procedure_spec.rb index 706c2a267..44e6b4a5f 100644 --- a/spec/models/procedure_spec.rb +++ b/spec/models/procedure_spec.rb @@ -307,9 +307,9 @@ describe Procedure do let(:procedure) { create :procedure } before do - create :dossier, procedure: procedure, state: :initiated + create :dossier, procedure: procedure, state: :en_construction create :dossier, procedure: procedure, state: :draft - create :dossier, procedure: procedure, state: :initiated + create :dossier, procedure: procedure, state: :en_construction end subject { procedure.total_dossier } @@ -331,7 +331,7 @@ describe Procedure do end context 'when there are some dossiers' do - let!(:dossier){ create(:dossier, procedure: procedure, state: 'initiated') } + let!(:dossier){ create(:dossier, procedure: procedure, state: 'en_construction') } let!(:dossier2){ create(:dossier, procedure: procedure, state: 'closed') } it { expect(subject[:data].size).to eq(2) } diff --git a/spec/models/search_spec.rb b/spec/models/search_spec.rb index dd46ea750..a2249d804 100644 --- a/spec/models/search_spec.rb +++ b/spec/models/search_spec.rb @@ -23,10 +23,10 @@ describe Search do 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_1) { create(:dossier, state: 'initiated', procedure: procedure_1, user: create(:user, email: 'contact@test.com')) } - let!(:dossier_2) { create(:dossier, state: 'initiated', procedure: procedure_1, user: create(:user, email: 'plop@gmail.com')) } - let!(:dossier_3) { create(:dossier, state: 'initiated', procedure: procedure_2, user: create(:user, email: 'peace@clap.fr')) } - let!(:dossier_archived) { create(:dossier, state: 'initiated', procedure: procedure_1, archived: true, user: create(:user, email: 'brouillonArchived@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')) } + let!(:dossier_archived) { create(:dossier, state: 'en_construction', procedure: procedure_1, archived: true, user: create(:user, email: 'brouillonArchived@clap.fr')) } let!(:etablissement_1) { create(:etablissement, entreprise: create(:entreprise, raison_sociale: 'OCTO Academy', dossier: dossier_1), dossier: dossier_1, siret: '41636169600051') } let!(:etablissement_2) { create(:etablissement, entreprise: create(:entreprise, raison_sociale: 'Plop octo', dossier: dossier_2), dossier: dossier_2, siret: '41816602300012') } diff --git a/spec/serializers/dossier_serializer_spec.rb b/spec/serializers/dossier_serializer_spec.rb new file mode 100644 index 000000000..aa340b2cc --- /dev/null +++ b/spec/serializers/dossier_serializer_spec.rb @@ -0,0 +1,12 @@ +describe DossierSerializer do + describe '#attributes' do + subject { DossierSerializer.new(dossier).serializable_hash } + + context 'when the dossier is en_construction' do + let(:dossier) { create(:dossier, :en_construction) } + + it { is_expected.to include(initiated_at: dossier.en_construction_at) } + it { is_expected.to include(state: 'initiated') } + end + end +end diff --git a/spec/serializers/dossier_table_export_serializer_spec.rb b/spec/serializers/dossier_table_export_serializer_spec.rb index 7f20c03aa..b39bff3f7 100644 --- a/spec/serializers/dossier_table_export_serializer_spec.rb +++ b/spec/serializers/dossier_table_export_serializer_spec.rb @@ -1,6 +1,17 @@ require 'spec_helper' describe DossierTableExportSerializer do + describe '#attributes' do + subject { DossierTableExportSerializer.new(dossier).serializable_hash } + + context 'when the dossier is en_construction' do + let(:dossier) { create(:dossier, :en_construction) } + + it { is_expected.to include(initiated_at: dossier.en_construction_at) } + it { is_expected.to include(state: 'initiated') } + end + end + describe '#emails_accompagnateurs' do let(:gestionnaire){ create(:gestionnaire) } let(:gestionnaire2) { create :gestionnaire} diff --git a/spec/serializers/dossiers_serializer_spec.rb b/spec/serializers/dossiers_serializer_spec.rb new file mode 100644 index 000000000..f2259574e --- /dev/null +++ b/spec/serializers/dossiers_serializer_spec.rb @@ -0,0 +1,11 @@ +describe DossiersSerializer do + describe '#attributes' do + subject { DossiersSerializer.new(dossier).serializable_hash } + + context 'when the dossier is en_construction' do + let(:dossier) { create(:dossier, :en_construction) } + + it { is_expected.to include(initiated_at: dossier.en_construction_at) } + end + end +end diff --git a/spec/services/dossiers_list_gestionnaire_service_spec.rb b/spec/services/dossiers_list_gestionnaire_service_spec.rb index 2e1e8d164..679603008 100644 --- a/spec/services/dossiers_list_gestionnaire_service_spec.rb +++ b/spec/services/dossiers_list_gestionnaire_service_spec.rb @@ -346,15 +346,15 @@ describe DossiersListGestionnaireService do describe 'state filter methods' do let!(:procedure) { create :procedure } let!(:dossier) { create(:dossier, procedure: procedure, state: 'draft') } - let!(:dossier2) { create(:dossier, procedure: procedure, state: 'initiated') } #nouveaux - let!(:dossier3) { create(:dossier, procedure: procedure, state: 'initiated') } #nouveaux + 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 let!(:dossier7) { create(:dossier, procedure: procedure, state: 'received') } #a_instruire let!(:dossier8) { create(:dossier, procedure: procedure, state: 'closed') } #termine let!(:dossier9) { create(:dossier, procedure: procedure, state: 'refused') } #termine let!(:dossier10) { create(:dossier, procedure: procedure, state: 'without_continuation') } #termine let!(:dossier11) { create(:dossier, procedure: procedure, state: 'closed') } #termine - let!(:dossier12) { create(:dossier, procedure: procedure, state: 'initiated', archived: true) } #a_traiter #archived + let!(:dossier12) { create(:dossier, procedure: procedure, state: 'en_construction', archived: true) } #a_traiter #archived let!(:dossier14) { create(:dossier, procedure: procedure, state: 'closed', archived: true) } #termine #archived describe '#termine' do diff --git a/spec/services/user_routes_authorization_service_spec.rb b/spec/services/user_routes_authorization_service_spec.rb index 03a5b805b..8fd8a2d2c 100644 --- a/spec/services/user_routes_authorization_service_spec.rb +++ b/spec/services/user_routes_authorization_service_spec.rb @@ -18,8 +18,8 @@ describe UserRoutesAuthorizationService do it { is_expected.to be_truthy } end - describe 'initiated' do - let(:state) { 'initiated' } + describe 'en_construction' do + let(:state) { 'en_construction' } it { is_expected.to be_falsey } end @@ -38,8 +38,8 @@ describe UserRoutesAuthorizationService do it { is_expected.to be_falsey } end - describe 'initiated' do - let(:state) { 'initiated' } + describe 'en_construction' do + let(:state) { 'en_construction' } it { is_expected.to be_falsey } end @@ -57,8 +57,8 @@ describe UserRoutesAuthorizationService do it { is_expected.to be_truthy } end - describe 'initiated' do - let(:state) { 'initiated' } + describe 'en_construction' do + let(:state) { 'en_construction' } it { is_expected.to be_truthy } end @@ -77,8 +77,8 @@ describe UserRoutesAuthorizationService do it { is_expected.to be_truthy } end - describe 'initiated' do - let(:state) { 'initiated' } + describe 'en_construction' do + let(:state) { 'en_construction' } it { is_expected.to be_truthy } end @@ -96,8 +96,8 @@ describe UserRoutesAuthorizationService do it { is_expected.to be_falsey } end - describe 'initiated' do - let(:state) { 'initiated' } + describe 'en_construction' do + let(:state) { 'en_construction' } it { is_expected.to be_truthy } end diff --git a/spec/views/admin/previsualisations/show.html.haml_spec.rb b/spec/views/admin/previsualisations/show.html.haml_spec.rb index 0677ee177..eb0e90b3f 100644 --- a/spec/views/admin/previsualisations/show.html.haml_spec.rb +++ b/spec/views/admin/previsualisations/show.html.haml_spec.rb @@ -45,7 +45,7 @@ describe 'admin/previsualisations/show.html.haml', type: :view do context 'si la page précédente est recapitularif' do before do - dossier.initiated! + dossier.en_construction! dossier.reload render end diff --git a/spec/views/backoffice/dossiers/index_html.haml_spec.rb b/spec/views/backoffice/dossiers/index_html.haml_spec.rb index bfade3965..105e99c0b 100644 --- a/spec/views/backoffice/dossiers/index_html.haml_spec.rb +++ b/spec/views/backoffice/dossiers/index_html.haml_spec.rb @@ -6,7 +6,7 @@ describe 'backoffice/dossiers/index.html.haml', type: :view do let!(:procedure) { create(:procedure, :published, administrateur: administrateur) } - let!(:decorate_dossier_initiated) { create(:dossier, :with_entreprise, procedure: procedure, state: 'initiated').decorate } + let!(:decorate_dossier_en_construction) { create(:dossier, :with_entreprise, procedure: procedure, state: 'en_construction').decorate } let!(:decorate_dossier_received) { create(:dossier, :with_entreprise, procedure: procedure, state: 'received').decorate } let!(:decorate_dossier_closed) { create(:dossier, :with_entreprise, procedure: procedure, state: 'closed').decorate } let!(:decorate_dossier_refused) { create(:dossier, :with_entreprise, procedure: procedure, state: 'refused').decorate } 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 17009aa9c..f0372a04e 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 @@ -28,8 +28,8 @@ describe 'layouts/left_panels/_left_panel_backoffice_dossierscontroller_show.htm it { expect(rendered).to have_link('Passer en instruction') } end - context 'when dossier have state initiated' do - let(:state) { 'initiated' } + context 'when dossier have state en_construction' do + let(:state) { 'en_construction' } before do render 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 831f61295..2e1ba02c2 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 @@ -11,8 +11,8 @@ describe 'layouts/left_panels/_left_panel_users_recapitulatifcontroller_show.htm end context 'buttons to change dossier state' do - context 'when dossier state is initiated' do - let(:state) { 'initiated' } + context 'when dossier state is en_construction' do + let(:state) { 'en_construction' } before do render end diff --git a/spec/views/new_gestionnaire/dossiers/show.html.haml_spec.rb b/spec/views/new_gestionnaire/dossiers/show.html.haml_spec.rb index 966912d4f..382838b3c 100644 --- a/spec/views/new_gestionnaire/dossiers/show.html.haml_spec.rb +++ b/spec/views/new_gestionnaire/dossiers/show.html.haml_spec.rb @@ -4,7 +4,7 @@ describe 'new_gestionnaire/dossiers/show.html.haml', type: :view do let(:current_gestionnaire) { create(:gestionnaire) } let(:individual) { nil } let(:entreprise) { nil } - let(:dossier) { create(:dossier, :initiated, entreprise: entreprise, individual: individual) } + let(:dossier) { create(:dossier, :en_construction, entreprise: entreprise, individual: individual) } before do assign(:dossier, dossier) diff --git a/spec/views/new_gestionnaire/procedures/_download_dossiers.html.haml_spec.rb b/spec/views/new_gestionnaire/procedures/_download_dossiers.html.haml_spec.rb index 6c273961e..334e97ef8 100644 --- a/spec/views/new_gestionnaire/procedures/_download_dossiers.html.haml_spec.rb +++ b/spec/views/new_gestionnaire/procedures/_download_dossiers.html.haml_spec.rb @@ -14,7 +14,7 @@ describe 'new_gestionnaire/procedures/_download_dossiers.html.haml', type: :view end context "when procedure has at least 1 dossier en construction" do - let!(:dossier) { create(:dossier, :initiated, procedure: procedure) } + let!(:dossier) { create(:dossier, :en_construction, procedure: procedure) } it { is_expected.to include("Télécharger tous les dossiers") } end end diff --git a/spec/views/users/carte/show.html.haml_spec.rb b/spec/views/users/carte/show.html.haml_spec.rb index 325683e43..6383ad295 100644 --- a/spec/views/users/carte/show.html.haml_spec.rb +++ b/spec/views/users/carte/show.html.haml_spec.rb @@ -38,7 +38,7 @@ describe 'users/carte/show.html.haml', type: :view do end context 'si la page précédente est recapitularif' do - let(:state) { 'initiated' } + let(:state) { 'en_construction' } 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 1e35f5d5b..21c284fc4 100644 --- a/spec/views/users/description/show.html.haml_spec.rb +++ b/spec/views/users/description/show.html.haml_spec.rb @@ -42,7 +42,7 @@ describe 'users/description/show.html.haml', type: :view do context 'si la page précédente est recapitularif' do before do - dossier.initiated! + dossier.en_construction! dossier.reload render end diff --git a/spec/views/users/dossiers/index_html.haml_spec.rb b/spec/views/users/dossiers/index_html.haml_spec.rb index a8c6e9e11..993595624 100644 --- a/spec/views/users/dossiers/index_html.haml_spec.rb +++ b/spec/views/users/dossiers/index_html.haml_spec.rb @@ -3,12 +3,12 @@ require 'spec_helper' describe 'users/dossiers/index.html.haml', type: :view do let(:user) { create(:user) } - let!(:decorate_dossier_initiated) { create(:dossier, :with_entreprise, user: user, state: 'initiated').decorate } + let!(:decorate_dossier_en_construction) { create(:dossier, :with_entreprise, user: user, state: 'en_construction').decorate } let!(:decorate_dossier_received) { create(:dossier, :with_entreprise, user: user, state: 'received').decorate } let!(:decorate_dossier_closed) { create(:dossier, :with_entreprise, user: user, state: 'closed').decorate } let!(:decorate_dossier_refused) { create(:dossier, :with_entreprise, user: user, state: 'refused').decorate } let!(:decorate_dossier_without_continuation) { create(:dossier, :with_entreprise, user: user, state: 'without_continuation').decorate } - let!(:decorate_dossier_invite) { create(:dossier, :with_entreprise, user: create(:user), state: 'initiated').decorate } + let!(:decorate_dossier_invite) { create(:dossier, :with_entreprise, user: create(:user), state: 'en_construction').decorate } before do create :invite, dossier: decorate_dossier_invite, user: user @@ -45,7 +45,7 @@ describe 'users/dossiers/index.html.haml', type: :view do let(:liste) { 'a_traiter' } it_behaves_like 'check_tab_content' do - let(:decorate_dossier_at_check) { decorate_dossier_initiated } + let(:decorate_dossier_at_check) { decorate_dossier_en_construction } end end diff --git a/spec/views/users/recapitulatif/show.html.haml_spec.rb b/spec/views/users/recapitulatif/show.html.haml_spec.rb index 7761bca13..b6e1de965 100644 --- a/spec/views/users/recapitulatif/show.html.haml_spec.rb +++ b/spec/views/users/recapitulatif/show.html.haml_spec.rb @@ -59,8 +59,8 @@ describe 'users/recapitulatif/show.html.haml', type: :view do end end - context 'when dossier state is initiated' do - let(:state) { 'initiated' } + context 'when dossier state is en_construction' do + let(:state) { 'en_construction' } before do render end