Use enum to the fullest with Dossier.states
This commit is contained in:
parent
ee25bba38c
commit
4b071ecf06
52 changed files with 221 additions and 221 deletions
|
@ -68,7 +68,7 @@ L'application tourne à l'adresse `http://localhost:3000`. Un utilisateur de tes
|
|||
|
||||
AutoArchiveProcedureJob.set(cron: "* * * * *").perform_later
|
||||
WeeklyOverviewJob.set(cron: "0 8 * * 0").perform_later
|
||||
AutoReceiveDossiersForProcedureJob.set(cron: "* * * * *").perform_later(procedure_declaratoire_id, 'en_instruction')
|
||||
AutoReceiveDossiersForProcedureJob.set(cron: "* * * * *").perform_later(procedure_declaratoire_id, Dossier.states.fetch(:en_instruction))
|
||||
FindDubiousProceduresJob.set(cron: "0 0 * * *").perform_later
|
||||
Administrateurs::ActivateBeforeExpirationJob.set(cron: "0 8 * * *").perform_later
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ module Manager
|
|||
|
||||
def change_state_to_instruction
|
||||
dossier = Dossier.find(params[:id])
|
||||
dossier.update(state: 'en_instruction', processed_at: nil, motivation: nil)
|
||||
dossier.update(state: Dossier.states.fetch(:en_instruction), processed_at: nil, motivation: nil)
|
||||
dossier.attestation&.destroy
|
||||
logger.info("Le dossier #{dossier.id} est repassé en instruction par #{current_administration.email}")
|
||||
flash[:notice] = "Le dossier #{dossier.id} est repassé en instruction"
|
||||
|
|
|
@ -7,7 +7,7 @@ class StatsController < ApplicationController
|
|||
|
||||
def index
|
||||
procedures = Procedure.publiees_ou_archivees
|
||||
dossiers = Dossier.where.not(:state => :brouillon)
|
||||
dossiers = Dossier.where.not(:state => Dossier.states.fetch(:brouillon))
|
||||
|
||||
@procedures_numbers = procedures_numbers(procedures)
|
||||
@dossiers_numbers = dossiers_numbers(dossiers)
|
||||
|
|
|
@ -51,7 +51,7 @@ class Users::DossiersController < UsersController
|
|||
procedure = Procedure.publiees.find(params[:procedure_id])
|
||||
end
|
||||
|
||||
dossier = Dossier.create!(procedure: procedure, user: current_user, state: 'brouillon')
|
||||
dossier = Dossier.create!(procedure: procedure, user: current_user, state: Dossier.states.fetch(:brouillon))
|
||||
siret = params[:siret] || current_user.siret
|
||||
|
||||
update_current_user_siret! siret if siret.present?
|
||||
|
|
|
@ -4,14 +4,14 @@ class AutoReceiveDossiersForProcedureJob < ApplicationJob
|
|||
def perform(procedure_id, state)
|
||||
procedure = Procedure.find(procedure_id)
|
||||
attrs = case state
|
||||
when 'en_instruction'
|
||||
when Dossier.states.fetch(:en_instruction)
|
||||
{
|
||||
state: :en_instruction,
|
||||
state: Dossier.states.fetch(:en_instruction),
|
||||
en_instruction_at: DateTime.now
|
||||
}
|
||||
when 'accepte'
|
||||
when Dossier.states.fetch(:accepte)
|
||||
{
|
||||
state: :accepte,
|
||||
state: Dossier.states.fetch(:accepte),
|
||||
en_instruction_at: DateTime.now,
|
||||
processed_at: DateTime.now
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ class AttestationTemplate < ApplicationRecord
|
|||
validates :footer, length: { maximum: 190 }
|
||||
|
||||
FILE_MAX_SIZE_IN_MB = 0.5
|
||||
DOSSIER_STATE = 'accepte'
|
||||
DOSSIER_STATE = Dossier.states.fetch(:accepte)
|
||||
|
||||
def attestation_for(dossier)
|
||||
Attestation.new(title: replace_tags(title, dossier), pdf: build_pdf(dossier))
|
||||
|
|
|
@ -54,7 +54,7 @@ module TagsSubstitutionConcern
|
|||
libelle: 'lien attestation',
|
||||
description: '',
|
||||
lambda: -> (d) { external_link(attestation_dossier_url(d)) },
|
||||
available_for_states: ['accepte']
|
||||
available_for_states: [Dossier.states.fetch(:accepte)]
|
||||
}
|
||||
]
|
||||
|
||||
|
|
|
@ -8,9 +8,9 @@ class Dossier < ApplicationRecord
|
|||
sans_suite: 'sans_suite'
|
||||
}
|
||||
|
||||
EN_CONSTRUCTION_OU_INSTRUCTION = %w(en_construction en_instruction)
|
||||
TERMINE = %w(accepte refuse sans_suite)
|
||||
INSTRUCTION_COMMENCEE = TERMINE + %w(en_instruction)
|
||||
EN_CONSTRUCTION_OU_INSTRUCTION = [states.fetch(:en_construction), states.fetch(:en_instruction)]
|
||||
TERMINE = [states.fetch(:accepte), states.fetch(:refuse), states.fetch(:sans_suite)]
|
||||
INSTRUCTION_COMMENCEE = TERMINE + [states.fetch(:en_instruction)]
|
||||
SOUMIS = EN_CONSTRUCTION_OU_INSTRUCTION + TERMINE
|
||||
|
||||
has_one :etablissement, dependent: :destroy
|
||||
|
@ -38,10 +38,10 @@ class Dossier < ApplicationRecord
|
|||
validates :autorisation_donnees, acceptance: { message: 'doit être coché' }, allow_nil: false, on: :update
|
||||
|
||||
default_scope { where(hidden_at: nil) }
|
||||
scope :state_brouillon, -> { where(state: 'brouillon') }
|
||||
scope :state_not_brouillon, -> { where.not(state: 'brouillon') }
|
||||
scope :state_en_construction, -> { where(state: 'en_construction') }
|
||||
scope :state_en_instruction, -> { where(state: 'en_instruction') }
|
||||
scope :state_brouillon, -> { where(state: states.fetch(:brouillon)) }
|
||||
scope :state_not_brouillon, -> { where.not(state: states.fetch(:brouillon)) }
|
||||
scope :state_en_construction, -> { where(state: states.fetch(:en_construction)) }
|
||||
scope :state_en_instruction, -> { where(state: states.fetch(:en_instruction)) }
|
||||
scope :state_en_construction_ou_instruction, -> { where(state: EN_CONSTRUCTION_OU_INSTRUCTION) }
|
||||
scope :state_instruction_commencee, -> { where(state: INSTRUCTION_COMMENCEE) }
|
||||
scope :state_termine, -> { where(state: TERMINE) }
|
||||
|
|
|
@ -7,7 +7,7 @@ module Mails
|
|||
SLUG = "closed_mail"
|
||||
DISPLAYED_NAME = "Accusé d'acceptation"
|
||||
DEFAULT_SUBJECT = 'Votre dossier demarches-simplifiees.fr nº --numéro du dossier-- a été accepté'
|
||||
DOSSIER_STATE = 'accepte'
|
||||
DOSSIER_STATE = Dossier.states.fetch(:accepte)
|
||||
|
||||
def self.default_template_name_for_procedure(procedure)
|
||||
attestation_template = procedure.attestation_template
|
||||
|
|
|
@ -8,6 +8,6 @@ module Mails
|
|||
DEFAULT_TEMPLATE_NAME = "notification_mailer/initiated_mail"
|
||||
DISPLAYED_NAME = 'Accusé de réception'
|
||||
DEFAULT_SUBJECT = 'Votre dossier demarches-simplifiees.fr nº --numéro du dossier-- a bien été reçu'
|
||||
DOSSIER_STATE = 'en_construction'
|
||||
DOSSIER_STATE = Dossier.states.fetch(:en_construction)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -8,6 +8,6 @@ module Mails
|
|||
DEFAULT_TEMPLATE_NAME = "notification_mailer/received_mail"
|
||||
DISPLAYED_NAME = 'Accusé de passage en instruction'
|
||||
DEFAULT_SUBJECT = 'Votre dossier demarches-simplifiees.fr nº --numéro du dossier-- va être instruit'
|
||||
DOSSIER_STATE = 'en_instruction'
|
||||
DOSSIER_STATE = Dossier.states.fetch(:en_instruction)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -8,6 +8,6 @@ module Mails
|
|||
DEFAULT_TEMPLATE_NAME = "notification_mailer/refused_mail"
|
||||
DISPLAYED_NAME = 'Accusé de rejet du dossier'
|
||||
DEFAULT_SUBJECT = 'Votre dossier demarches-simplifiees.fr nº --numéro du dossier-- a été refusé'
|
||||
DOSSIER_STATE = 'refuse'
|
||||
DOSSIER_STATE = Dossier.states.fetch(:refuse)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -8,6 +8,6 @@ module Mails
|
|||
DEFAULT_TEMPLATE_NAME = "notification_mailer/without_continuation_mail"
|
||||
DISPLAYED_NAME = 'Accusé de classement sans suite'
|
||||
DEFAULT_SUBJECT = 'Votre dossier demarches-simplifiees.fr nº --numéro du dossier-- a été classé sans suite'
|
||||
DOSSIER_STATE = 'sans_suite'
|
||||
DOSSIER_STATE = Dossier.states.fetch(:sans_suite)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -44,15 +44,15 @@ class DossierSerializer < ActiveModel::Serializer
|
|||
|
||||
def state
|
||||
case object.state
|
||||
when 'en_construction'
|
||||
when Dossier.states.fetch(:en_construction)
|
||||
'initiated'
|
||||
when 'en_instruction'
|
||||
when Dossier.states.fetch(:en_instruction)
|
||||
'received'
|
||||
when 'accepte'
|
||||
when Dossier.states.fetch(:accepte)
|
||||
'closed'
|
||||
when 'refuse'
|
||||
when Dossier.states.fetch(:refuse)
|
||||
'refused'
|
||||
when 'sans_suite'
|
||||
when Dossier.states.fetch(:sans_suite)
|
||||
'without_continuation'
|
||||
else
|
||||
object.state
|
||||
|
|
|
@ -23,15 +23,15 @@ class DossierTableExportSerializer < ActiveModel::Serializer
|
|||
|
||||
def state
|
||||
case object.state
|
||||
when 'en_construction'
|
||||
when Dossier.states.fetch(:en_construction)
|
||||
'initiated'
|
||||
when 'en_instruction'
|
||||
when Dossier.states.fetch(:en_instruction)
|
||||
'received'
|
||||
when 'accepte'
|
||||
when Dossier.states.fetch(:accepte)
|
||||
'closed'
|
||||
when 'refuse'
|
||||
when Dossier.states.fetch(:refuse)
|
||||
'refused'
|
||||
when 'sans_suite'
|
||||
when Dossier.states.fetch(:sans_suite)
|
||||
'without_continuation'
|
||||
else
|
||||
object.state
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
.col-xs-8.title-no-expanse
|
||||
.carret-right
|
||||
INFORMATIONS DU DEMANDEUR
|
||||
- if ["brouillon", "en_construction"].include?(@facade.dossier.state)
|
||||
- if [Dossier.states.fetch(:brouillon), Dossier.states.fetch(: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
|
||||
|
|
|
@ -124,7 +124,7 @@
|
|||
partenaires
|
||||
%li.number
|
||||
.number-value
|
||||
= number_with_delimiter(Dossier.where.not(:state => :brouillon).count, :locale => :fr)
|
||||
= number_with_delimiter(Dossier.where.not(:state => Dossier.states.fetch(:brouillon)).count, :locale => :fr)
|
||||
.number-label<
|
||||
dossiers
|
||||
%br<>
|
||||
|
|
|
@ -50,7 +50,7 @@
|
|||
partenaires
|
||||
%li.number
|
||||
.number-value
|
||||
= number_with_delimiter(Dossier.where.not(:state => :brouillon).count, :locale => :fr)
|
||||
= number_with_delimiter(Dossier.where.not(:state => Dossier.states.fetch(:brouillon)).count, :locale => :fr)
|
||||
.number-label<
|
||||
dossiers
|
||||
%br<>
|
||||
|
|
|
@ -83,8 +83,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: 'en_construction') }
|
||||
let!(:dossier2) { create(:dossier, :with_entreprise, procedure: procedure, state: 'en_construction') }
|
||||
let!(:dossier1) { create(:dossier, :with_entreprise, procedure: procedure, state: Dossier.states.fetch(:en_construction)) }
|
||||
let!(:dossier2) { create(:dossier, :with_entreprise, procedure: procedure, state: Dossier.states.fetch(:en_construction)) }
|
||||
|
||||
before do
|
||||
allow(controller).to receive(:per_page).and_return(1)
|
||||
|
|
|
@ -111,7 +111,7 @@ describe NewGestionnaire::DossiersController, type: :controller do
|
|||
dossier.reload
|
||||
end
|
||||
|
||||
it { expect(dossier.state).to eq('en_instruction') }
|
||||
it { expect(dossier.state).to eq(Dossier.states.fetch(:en_instruction)) }
|
||||
it { is_expected.to redirect_to gestionnaire_dossier_path(procedure, dossier) }
|
||||
it { expect(gestionnaire.follow?(dossier)).to be true }
|
||||
end
|
||||
|
@ -128,7 +128,7 @@ describe NewGestionnaire::DossiersController, type: :controller do
|
|||
subject
|
||||
|
||||
dossier.reload
|
||||
expect(dossier.state).to eq('en_construction')
|
||||
expect(dossier.state).to eq(Dossier.states.fetch(:en_construction))
|
||||
end
|
||||
|
||||
it { is_expected.to redirect_to gestionnaire_dossier_path(procedure, dossier) }
|
||||
|
@ -147,7 +147,7 @@ describe NewGestionnaire::DossiersController, type: :controller do
|
|||
subject
|
||||
|
||||
dossier.reload
|
||||
expect(dossier.state).to eq('refuse')
|
||||
expect(dossier.state).to eq(Dossier.states.fetch(:refuse))
|
||||
end
|
||||
|
||||
it 'Notification email is sent' do
|
||||
|
@ -173,7 +173,7 @@ describe NewGestionnaire::DossiersController, type: :controller do
|
|||
subject
|
||||
|
||||
dossier.reload
|
||||
expect(dossier.state).to eq('sans_suite')
|
||||
expect(dossier.state).to eq(Dossier.states.fetch(:sans_suite))
|
||||
end
|
||||
|
||||
it 'Notification email is sent' do
|
||||
|
@ -205,7 +205,7 @@ describe NewGestionnaire::DossiersController, type: :controller do
|
|||
subject
|
||||
|
||||
dossier.reload
|
||||
expect(dossier.state).to eq('accepte')
|
||||
expect(dossier.state).to eq(Dossier.states.fetch(:accepte))
|
||||
end
|
||||
|
||||
context 'when the dossier does not have any attestation' do
|
||||
|
|
|
@ -122,7 +122,7 @@ describe NewGestionnaire::ProceduresController, type: :controller do
|
|||
end
|
||||
|
||||
context "with brouillon state" do
|
||||
let(:state) { "brouillon" }
|
||||
let(:state) { Dossier.states.fetch(:brouillon) }
|
||||
before { subject }
|
||||
|
||||
it { expect(assigns(:dossiers_count_per_procedure)[procedure.id]).to eq(nil) }
|
||||
|
@ -134,17 +134,17 @@ describe NewGestionnaire::ProceduresController, type: :controller do
|
|||
|
||||
context "with not draft state on multiple procedures" do
|
||||
let(:procedure2) { create(:procedure, :published) }
|
||||
let(:state) { "en_construction" }
|
||||
let(:state) { Dossier.states.fetch(:en_construction) }
|
||||
|
||||
before do
|
||||
create(:dossier, procedure: procedure, state: "en_construction")
|
||||
create(:dossier, procedure: procedure, state: "en_instruction")
|
||||
create(:dossier, procedure: procedure, state: "sans_suite", archived: true)
|
||||
create(:dossier, procedure: procedure, state: Dossier.states.fetch(:en_construction))
|
||||
create(:dossier, procedure: procedure, state: Dossier.states.fetch(:en_instruction))
|
||||
create(:dossier, procedure: procedure, state: Dossier.states.fetch(:sans_suite), archived: true)
|
||||
|
||||
gestionnaire.procedures << procedure2
|
||||
create(:dossier, :followed, procedure: procedure2, state: "en_construction")
|
||||
create(:dossier, procedure: procedure2, state: "accepte")
|
||||
gestionnaire.followed_dossiers << create(:dossier, procedure: procedure2, state: "en_instruction")
|
||||
create(:dossier, :followed, procedure: procedure2, state: Dossier.states.fetch(:en_construction))
|
||||
create(:dossier, procedure: procedure2, state: Dossier.states.fetch(:accepte))
|
||||
gestionnaire.followed_dossiers << create(:dossier, procedure: procedure2, state: Dossier.states.fetch(:en_instruction))
|
||||
|
||||
subject
|
||||
end
|
||||
|
@ -182,7 +182,7 @@ describe NewGestionnaire::ProceduresController, type: :controller do
|
|||
end
|
||||
|
||||
context 'with a new brouillon dossier' do
|
||||
let!(:brouillon_dossier) { create(:dossier, procedure: procedure, state: 'brouillon') }
|
||||
let!(:brouillon_dossier) { create(:dossier, procedure: procedure, state: Dossier.states.fetch(:brouillon)) }
|
||||
|
||||
before do
|
||||
get :show, params: { procedure_id: procedure.id }
|
||||
|
@ -196,7 +196,7 @@ describe NewGestionnaire::ProceduresController, type: :controller do
|
|||
end
|
||||
|
||||
context 'with a new dossier without follower' do
|
||||
let!(:new_unfollow_dossier) { create(:dossier, procedure: procedure, state: 'en_instruction') }
|
||||
let!(:new_unfollow_dossier) { create(:dossier, procedure: procedure, state: Dossier.states.fetch(:en_instruction)) }
|
||||
|
||||
before do
|
||||
get :show, params: { procedure_id: procedure.id }
|
||||
|
@ -210,7 +210,7 @@ describe NewGestionnaire::ProceduresController, type: :controller do
|
|||
end
|
||||
|
||||
context 'with a new dossier with a follower' do
|
||||
let!(:new_followed_dossier) { create(:dossier, procedure: procedure, state: 'en_instruction') }
|
||||
let!(:new_followed_dossier) { create(:dossier, procedure: procedure, state: Dossier.states.fetch(:en_instruction)) }
|
||||
|
||||
before do
|
||||
gestionnaire.followed_dossiers << new_followed_dossier
|
||||
|
@ -225,7 +225,7 @@ describe NewGestionnaire::ProceduresController, type: :controller do
|
|||
end
|
||||
|
||||
context 'with a termine dossier with a follower' do
|
||||
let!(:termine_dossier) { create(:dossier, procedure: procedure, state: 'accepte') }
|
||||
let!(:termine_dossier) { create(:dossier, procedure: procedure, state: Dossier.states.fetch(:accepte)) }
|
||||
|
||||
before do
|
||||
get :show, params: { procedure_id: procedure.id }
|
||||
|
@ -239,7 +239,7 @@ describe NewGestionnaire::ProceduresController, type: :controller do
|
|||
end
|
||||
|
||||
context 'with an archived dossier' do
|
||||
let!(:archived_dossier) { create(:dossier, procedure: procedure, state: 'en_instruction', archived: true) }
|
||||
let!(:archived_dossier) { create(:dossier, procedure: procedure, state: Dossier.states.fetch(:en_instruction), archived: true) }
|
||||
|
||||
before do
|
||||
get :show, params: { procedure_id: procedure.id }
|
||||
|
@ -253,10 +253,10 @@ describe NewGestionnaire::ProceduresController, type: :controller do
|
|||
end
|
||||
|
||||
describe 'statut' do
|
||||
let!(:a_suivre__dossier) { Timecop.freeze(1.day.ago){ create(:dossier, procedure: procedure, state: 'en_instruction') } }
|
||||
let!(:new_followed_dossier) { Timecop.freeze(2.days.ago){ create(:dossier, procedure: procedure, state: 'en_instruction') } }
|
||||
let!(:termine_dossier) { Timecop.freeze(3.days.ago){ create(:dossier, procedure: procedure, state: 'accepte') } }
|
||||
let!(:archived_dossier) { Timecop.freeze(4.days.ago){ create(:dossier, procedure: procedure, state: 'en_instruction', archived: true) } }
|
||||
let!(:a_suivre__dossier) { Timecop.freeze(1.day.ago){ create(:dossier, procedure: procedure, state: Dossier.states.fetch(:en_instruction)) } }
|
||||
let!(:new_followed_dossier) { Timecop.freeze(2.days.ago){ create(:dossier, procedure: procedure, state: Dossier.states.fetch(:en_instruction)) } }
|
||||
let!(:termine_dossier) { Timecop.freeze(3.days.ago){ create(:dossier, procedure: procedure, state: Dossier.states.fetch(:accepte)) } }
|
||||
let!(:archived_dossier) { Timecop.freeze(4.days.ago){ create(:dossier, procedure: procedure, state: Dossier.states.fetch(:en_instruction), archived: true) } }
|
||||
|
||||
before do
|
||||
gestionnaire.followed_dossiers << new_followed_dossier
|
||||
|
|
|
@ -280,7 +280,7 @@ describe NewUser::DossiersController, type: :controller do
|
|||
|
||||
expect(response).to redirect_to(merci_dossier_path(dossier))
|
||||
expect(first_champ.reload.value).to eq('beautiful value')
|
||||
expect(dossier.reload.state).to eq('en_construction')
|
||||
expect(dossier.reload.state).to eq(Dossier.states.fetch(:en_construction))
|
||||
end
|
||||
|
||||
context "on an archived procedure" do
|
||||
|
@ -290,7 +290,7 @@ describe NewUser::DossiersController, type: :controller do
|
|||
subject
|
||||
|
||||
expect(response).not_to redirect_to(merci_dossier_path(dossier))
|
||||
expect(dossier.reload.state).to eq('brouillon')
|
||||
expect(dossier.reload.state).to eq(Dossier.states.fetch(:brouillon))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -357,7 +357,7 @@ describe NewUser::DossiersController, type: :controller do
|
|||
|
||||
it { expect(response).to render_template(:modifier) }
|
||||
it { expect(flash.notice).to eq('Votre brouillon a bien été sauvegardé.') }
|
||||
it { expect(dossier.reload.state).to eq('brouillon') }
|
||||
it { expect(dossier.reload.state).to eq(Dossier.states.fetch(:brouillon)) }
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -387,7 +387,7 @@ describe NewUser::DossiersController, type: :controller do
|
|||
|
||||
it { expect(response).to render_template(:modifier) }
|
||||
it { expect(flash.notice).to eq('Votre brouillon a bien été sauvegardé.') }
|
||||
it { expect(dossier.reload.state).to eq('brouillon') }
|
||||
it { expect(dossier.reload.state).to eq(Dossier.states.fetch(:brouillon)) }
|
||||
end
|
||||
|
||||
context 'and the invite tries to submit the dossier' do
|
||||
|
@ -404,7 +404,7 @@ describe NewUser::DossiersController, type: :controller do
|
|||
end
|
||||
|
||||
it { expect(first_champ.reload.value).to eq('beautiful value') }
|
||||
it { expect(dossier.reload.state).to eq('en_construction') }
|
||||
it { expect(dossier.reload.state).to eq(Dossier.states.fetch(:en_construction)) }
|
||||
it { expect(response).to redirect_to(users_dossiers_invite_path(invite)) }
|
||||
end
|
||||
end
|
||||
|
|
|
@ -162,7 +162,7 @@ describe StatsController, type: :controller do
|
|||
:processed_at => 2.months.ago.beginning_of_month + 4.days)
|
||||
|
||||
# Write directly in the DB to avoid the before_validation hook
|
||||
Dossier.update_all(state: "accepte")
|
||||
Dossier.update_all(state: Dossier.states.fetch(:accepte))
|
||||
|
||||
@expected_hash = {
|
||||
"#{2.months.ago.beginning_of_month}" => 3.0,
|
||||
|
@ -170,7 +170,7 @@ describe StatsController, type: :controller do
|
|||
}
|
||||
end
|
||||
|
||||
let (:association) { Dossier.where.not(:state => :brouillon) }
|
||||
let (:association) { Dossier.where.not(:state => Dossier.states.fetch(:brouillon)) }
|
||||
|
||||
subject { StatsController.new.send(:dossier_instruction_mean_time, association) }
|
||||
|
||||
|
@ -214,7 +214,7 @@ describe StatsController, type: :controller do
|
|||
:processed_at => 2.months.ago.beginning_of_month + 1.day)
|
||||
|
||||
# Write directly in the DB to avoid the before_validation hook
|
||||
Dossier.update_all(state: "accepte")
|
||||
Dossier.update_all(state: Dossier.states.fetch(:accepte))
|
||||
|
||||
@expected_hash = {
|
||||
"#{2.months.ago.beginning_of_month}" => 30.0,
|
||||
|
@ -222,7 +222,7 @@ describe StatsController, type: :controller do
|
|||
}
|
||||
end
|
||||
|
||||
let (:association) { Dossier.where.not(:state => :brouillon) }
|
||||
let (:association) { Dossier.where.not(:state => Dossier.states.fetch(:brouillon)) }
|
||||
|
||||
subject { StatsController.new.send(:dossier_filling_mean_time, association) }
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ shared_examples 'carte_controller_spec' do
|
|||
context 'when dossier’s procedure have api carto actived' do
|
||||
context 'when dossier does not have a valid state' do
|
||||
before do
|
||||
dossier.state = 'en_instruction'
|
||||
dossier.state = Dossier.states.fetch(:en_instruction)
|
||||
dossier.save
|
||||
|
||||
get :show, params: { dossier_id: dossier.id }
|
||||
|
@ -60,7 +60,7 @@ shared_examples 'carte_controller_spec' do
|
|||
|
||||
describe 'POST #save' do
|
||||
context 'it cleans json_latlngs' do
|
||||
let(:dossier) { create(:dossier, state: 'en_construction') }
|
||||
let(:dossier) { create(:dossier, state: Dossier.states.fetch(:en_construction)) }
|
||||
let(:json_latlngs) { multipolygon.to_json }
|
||||
|
||||
before do
|
||||
|
@ -99,7 +99,7 @@ shared_examples 'carte_controller_spec' do
|
|||
end
|
||||
|
||||
context 'En train de modifier la localisation' do
|
||||
let(:dossier) { create(:dossier, state: 'en_construction') }
|
||||
let(:dossier) { create(:dossier, state: Dossier.states.fetch(:en_construction)) }
|
||||
before do
|
||||
post :save, params: { dossier_id: dossier.id, json_latlngs: '' }
|
||||
end
|
||||
|
|
|
@ -53,7 +53,7 @@ describe Users::Dossiers::InvitesController, type: :controller do
|
|||
let(:email) { user.email }
|
||||
|
||||
context 'and dossier is a brouillon' do
|
||||
let(:dossier) { create :dossier, state: 'brouillon' }
|
||||
let(:dossier) { create :dossier, state: Dossier.states.fetch(:brouillon) }
|
||||
|
||||
it { is_expected.to have_http_status(302) }
|
||||
it { is_expected.to redirect_to modifier_dossier_path(dossier) }
|
||||
|
|
|
@ -39,7 +39,7 @@ describe Users::DossiersController, type: :controller do
|
|||
describe 'before_action authorized_routes?' do
|
||||
context 'when dossier does not have a valid state' do
|
||||
before do
|
||||
dossier.state = 'en_instruction'
|
||||
dossier.state = Dossier.states.fetch(:en_instruction)
|
||||
dossier.save
|
||||
|
||||
get :show, params: { id: dossier.id }
|
||||
|
@ -264,7 +264,7 @@ describe Users::DossiersController, type: :controller do
|
|||
|
||||
it 'state of dossier is brouillon' do
|
||||
subject
|
||||
expect(Dossier.last.state).to eq('brouillon')
|
||||
expect(Dossier.last.state).to eq(Dossier.states.fetch(:brouillon))
|
||||
end
|
||||
|
||||
describe 'get rna informations' do
|
||||
|
@ -393,8 +393,8 @@ describe Users::DossiersController, type: :controller do
|
|||
|
||||
describe 'DELETE #destroy' do
|
||||
let(:user) { create(:user) }
|
||||
let!(:dossier_brouillon) { create :dossier, state: "brouillon", user: user }
|
||||
let!(:dossier_not_brouillon) { create :dossier, state: "en_construction", user: user }
|
||||
let!(:dossier_brouillon) { create :dossier, state: Dossier.states.fetch(:brouillon), user: user }
|
||||
let!(:dossier_not_brouillon) { create :dossier, state: Dossier.states.fetch(:en_construction), user: user }
|
||||
|
||||
subject { delete :destroy, params: { id: dossier.id } }
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Users::RecapitulatifController, type: :controller do
|
||||
let(:dossier) { create(:dossier, state: 'en_construction') }
|
||||
let(:dossier) { create(:dossier, state: Dossier.states.fetch(:en_construction)) }
|
||||
let(:bad_dossier_id) { Dossier.count + 100000 }
|
||||
|
||||
before do
|
||||
|
@ -24,7 +24,7 @@ describe Users::RecapitulatifController, type: :controller do
|
|||
describe 'before_action authorized_routes?' do
|
||||
context 'when dossier have brouillon state' do
|
||||
before do
|
||||
dossier.state = 'brouillon'
|
||||
dossier.state = Dossier.states.fetch(:brouillon)
|
||||
dossier.save
|
||||
|
||||
get :show, params: { dossier_id: dossier.id }
|
||||
|
@ -43,7 +43,7 @@ describe Users::RecapitulatifController, type: :controller do
|
|||
|
||||
it 'dossier change his state for accepte' do
|
||||
dossier.reload
|
||||
expect(dossier.state).to eq('en_construction')
|
||||
expect(dossier.state).to eq(Dossier.states.fetch(:en_construction))
|
||||
end
|
||||
|
||||
it 'a message informe user what his dossier is en_construction' do
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
FactoryBot.define do
|
||||
factory :deleted_dossier do
|
||||
dossier_id 1111
|
||||
state 'en_construction'
|
||||
state Dossier.states.fetch(:en_construction)
|
||||
deleted_at DateTime.now
|
||||
|
||||
association :procedure, :published
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
FactoryBot.define do
|
||||
factory :dossier do
|
||||
autorisation_donnees true
|
||||
state 'brouillon'
|
||||
state Dossier.states.fetch(:brouillon)
|
||||
association :user, factory: [:user]
|
||||
|
||||
before(:create) do |dossier, _evaluator|
|
||||
|
@ -73,7 +73,7 @@ FactoryBot.define do
|
|||
|
||||
trait :en_construction do
|
||||
after(:create) do |dossier, _evaluator|
|
||||
dossier.state = 'en_construction'
|
||||
dossier.state = Dossier.states.fetch(:en_construction)
|
||||
dossier.en_construction_at = dossier.created_at + 1.minute
|
||||
dossier.save!
|
||||
end
|
||||
|
@ -81,7 +81,7 @@ FactoryBot.define do
|
|||
|
||||
trait :en_instruction do
|
||||
after(:create) do |dossier, _evaluator|
|
||||
dossier.state = 'en_instruction'
|
||||
dossier.state = Dossier.states.fetch(:en_instruction)
|
||||
dossier.en_construction_at = dossier.created_at + 1.minute
|
||||
dossier.created_at = dossier.created_at + 2.minutes
|
||||
dossier.save!
|
||||
|
@ -90,7 +90,7 @@ FactoryBot.define do
|
|||
|
||||
trait :accepte do
|
||||
after(:create) do |dossier, _evaluator|
|
||||
dossier.state = 'accepte'
|
||||
dossier.state = Dossier.states.fetch(:accepte)
|
||||
dossier.processed_at = dossier.created_at + 1.minute
|
||||
dossier.en_construction_at = dossier.created_at + 2.minutes
|
||||
dossier.created_at = dossier.created_at + 3.minutes
|
||||
|
@ -100,7 +100,7 @@ FactoryBot.define do
|
|||
|
||||
trait :refuse do
|
||||
after(:create) do |dossier, _evaluator|
|
||||
dossier.state = 'refuse'
|
||||
dossier.state = Dossier.states.fetch(:refuse)
|
||||
dossier.processed_at = dossier.created_at + 1.minute
|
||||
dossier.en_construction_at = dossier.created_at + 2.minutes
|
||||
dossier.created_at = dossier.created_at + 3.minutes
|
||||
|
@ -110,7 +110,7 @@ FactoryBot.define do
|
|||
|
||||
trait :sans_suite do
|
||||
after(:create) do |dossier, _evaluator|
|
||||
dossier.state = 'sans_suite'
|
||||
dossier.state = Dossier.states.fetch(:sans_suite)
|
||||
dossier.processed_at = dossier.created_at + 1.minute
|
||||
dossier.en_construction_at = dossier.created_at + 2.minutes
|
||||
dossier.created_at = dossier.created_at + 3.minutes
|
||||
|
@ -121,9 +121,9 @@ FactoryBot.define do
|
|||
trait :with_motivation do
|
||||
after(:create) do |dossier, _evaluator|
|
||||
dossier.motivation = case dossier.state
|
||||
when 'refuse'
|
||||
when Dossier.states.fetch(:refuse)
|
||||
'L’entreprise concernée n’est pas agréée.'
|
||||
when 'sans_suite'
|
||||
when Dossier.states.fetch(:sans_suite)
|
||||
'Le département n’est pas éligible. Veuillez remplir un nouveau dossier auprès de la DDT du 93.'
|
||||
else
|
||||
'Vous avez validé les conditions.'
|
||||
|
|
|
@ -7,7 +7,7 @@ feature 'The gestionnaire part' do
|
|||
let!(:gestionnaire) { create(:gestionnaire, password: password) }
|
||||
|
||||
let!(:procedure) { create(:procedure, :published, gestionnaires: [gestionnaire]) }
|
||||
let!(:dossier) { create(:dossier, state: :en_construction, procedure: procedure) }
|
||||
let!(:dossier) { create(:dossier, state: Dossier.states.fetch(:en_construction), procedure: procedure) }
|
||||
|
||||
scenario 'A gestionnaire can accept a dossier' do
|
||||
log_in(gestionnaire.email, password)
|
||||
|
@ -22,7 +22,7 @@ feature 'The gestionnaire part' do
|
|||
|
||||
click_on 'Passer en instruction'
|
||||
dossier.reload
|
||||
expect(dossier.state).to eq('en_instruction')
|
||||
expect(dossier.state).to eq(Dossier.states.fetch(:en_instruction))
|
||||
|
||||
within('.accept.motivation') do
|
||||
fill_in('dossier_motivation', with: 'a good reason')
|
||||
|
@ -30,7 +30,7 @@ feature 'The gestionnaire part' do
|
|||
end
|
||||
|
||||
dossier.reload
|
||||
expect(dossier.state).to eq('accepte')
|
||||
expect(dossier.state).to eq(Dossier.states.fetch(:accepte))
|
||||
expect(dossier.motivation).to eq('a good reason')
|
||||
end
|
||||
|
||||
|
|
|
@ -4,9 +4,9 @@ feature "procedure filters" do
|
|||
let(:procedure) { create(:procedure, :published, :with_type_de_champ) }
|
||||
let(:gestionnaire) { create(:gestionnaire, procedures: [procedure]) }
|
||||
let!(:type_de_champ) { procedure.types_de_champ.first }
|
||||
let!(:new_unfollow_dossier) { create(:dossier, procedure: procedure, state: "en_instruction") }
|
||||
let!(:new_unfollow_dossier) { create(:dossier, procedure: procedure, state: Dossier.states.fetch(:en_instruction)) }
|
||||
let!(:champ) { Champ.find_by(type_de_champ_id: type_de_champ.id, dossier_id: new_unfollow_dossier.id) }
|
||||
let!(:new_unfollow_dossier_2) { create(:dossier, procedure: procedure, state: "en_instruction") }
|
||||
let!(:new_unfollow_dossier_2) { create(:dossier, procedure: procedure, state: Dossier.states.fetch(:en_instruction)) }
|
||||
|
||||
before do
|
||||
champ.update(value: "Mon champ rempli")
|
||||
|
|
|
@ -7,7 +7,7 @@ feature 'Invitations' do
|
|||
let(:invite) { create(:invite_user, user: invited_user, dossier: dossier) }
|
||||
|
||||
context 'when the dossier is a brouillon' do
|
||||
let!(:dossier) { create(:dossier, :for_individual, state: 'brouillon', user: user, procedure: procedure) }
|
||||
let!(:dossier) { create(:dossier, :for_individual, state: Dossier.states.fetch(:brouillon), user: user, procedure: procedure) }
|
||||
|
||||
scenario 'on the form, a user can invite another user to collaborate on the dossier', js: true do
|
||||
log_in(user)
|
||||
|
|
|
@ -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: 'en_construction') }
|
||||
let!(:dossier1) { create(:dossier, :with_entreprise, user: user, state: 'en_construction') }
|
||||
let!(:last_updated_dossier) { create(:dossier, :with_entreprise, user: user, state: Dossier.states.fetch(:en_construction)) }
|
||||
let!(:dossier1) { create(:dossier, :with_entreprise, user: user, state: Dossier.states.fetch(:en_construction)) }
|
||||
let!(:dossier2) { create(:dossier, :with_entreprise) }
|
||||
let!(:dossier_archived) { create(:dossier, :with_entreprise, user: user, state: 'en_construction') }
|
||||
let!(:dossier_archived) { create(:dossier, :with_entreprise, user: user, state: Dossier.states.fetch(:en_construction)) }
|
||||
let(:dossiers_per_page) { 25 }
|
||||
|
||||
before do
|
||||
|
|
|
@ -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: "en_construction") }
|
||||
let(:dossier) { create(:dossier, :with_entreprise, user: user, state: Dossier.states.fetch(:en_construction)) }
|
||||
let(:dossier_id) { dossier.id }
|
||||
|
||||
let(:champ1) { dossier.champs.first }
|
||||
|
|
|
@ -30,19 +30,19 @@ RSpec.describe DossierHelper, type: :helper do
|
|||
subject { url_for_dossier(dossier) }
|
||||
|
||||
context "when the dossier is in the brouillon state" do
|
||||
let(:dossier) { create(:dossier, state: 'brouillon') }
|
||||
let(:dossier) { create(:dossier, state: Dossier.states.fetch(:brouillon)) }
|
||||
it { is_expected.to eq "/dossiers/#{dossier.id}/modifier" }
|
||||
end
|
||||
|
||||
context "when the dossier is any other state" do
|
||||
let(:dossier) { create(:dossier, state: 'en_construction') }
|
||||
let(:dossier) { create(:dossier, state: Dossier.states.fetch(:en_construction)) }
|
||||
it { is_expected.to eq "/users/dossiers/#{dossier.id}/recapitulatif" }
|
||||
end
|
||||
end
|
||||
|
||||
describe ".dossier_submission_is_closed?" do
|
||||
let(:dossier) { create(:dossier, state: state) }
|
||||
let(:state) { "brouillon" }
|
||||
let(:state) { Dossier.states.fetch(:brouillon) }
|
||||
|
||||
subject { dossier_submission_is_closed?(dossier) }
|
||||
|
||||
|
@ -67,31 +67,31 @@ RSpec.describe DossierHelper, type: :helper do
|
|||
end
|
||||
|
||||
context "when dossier state is en_construction" do
|
||||
let(:state) { "en_construction" }
|
||||
let(:state) { Dossier.states.fetch(:en_construction) }
|
||||
|
||||
it_behaves_like "returns false"
|
||||
end
|
||||
|
||||
context "when dossier state is en_construction" do
|
||||
let(:state) { "en_instruction" }
|
||||
let(:state) { Dossier.states.fetch(:en_instruction) }
|
||||
|
||||
it_behaves_like "returns false"
|
||||
end
|
||||
|
||||
context "when dossier state is en_construction" do
|
||||
let(:state) { "accepte" }
|
||||
let(:state) { Dossier.states.fetch(:accepte) }
|
||||
|
||||
it_behaves_like "returns false"
|
||||
end
|
||||
|
||||
context "when dossier state is en_construction" do
|
||||
let(:state) { "refuse" }
|
||||
let(:state) { Dossier.states.fetch(:refuse) }
|
||||
|
||||
it_behaves_like "returns false"
|
||||
end
|
||||
|
||||
context "when dossier state is en_construction" do
|
||||
let(:state) { "sans_suite" }
|
||||
let(:state) { Dossier.states.fetch(:sans_suite) }
|
||||
|
||||
it_behaves_like "returns false"
|
||||
end
|
||||
|
|
|
@ -18,15 +18,15 @@ 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: '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) }
|
||||
let!(:dossier5) { create(:dossier, procedure: procedure_hier, state: 'en_instruction', archived: false) }
|
||||
let!(:dossier6) { create(:dossier, procedure: procedure_hier, state: 'accepte', archived: false) }
|
||||
let!(:dossier7) { create(:dossier, procedure: procedure_hier, state: 'refuse', archived: false) }
|
||||
let!(:dossier8) { create(:dossier, procedure: procedure_hier, state: 'sans_suite', archived: false) }
|
||||
let!(:dossier9) { create(:dossier, procedure: procedure_aujourdhui, state: 'en_construction', archived: false) }
|
||||
let!(:dossier1) { create(:dossier, procedure: procedure_hier, state: Dossier.states.fetch(:brouillon), archived: false) }
|
||||
let!(:dossier2) { create(:dossier, procedure: procedure_hier, state: Dossier.states.fetch(:en_construction), archived: false) }
|
||||
let!(:dossier3) { create(:dossier, procedure: procedure_hier, state: Dossier.states.fetch(:en_construction), archived: false) }
|
||||
let!(:dossier4) { create(:dossier, procedure: procedure_hier, state: Dossier.states.fetch(:en_construction), archived: false) }
|
||||
let!(:dossier5) { create(:dossier, procedure: procedure_hier, state: Dossier.states.fetch(:en_instruction), archived: false) }
|
||||
let!(:dossier6) { create(:dossier, procedure: procedure_hier, state: Dossier.states.fetch(:accepte), archived: false) }
|
||||
let!(:dossier7) { create(:dossier, procedure: procedure_hier, state: Dossier.states.fetch(:refuse), archived: false) }
|
||||
let!(:dossier8) { create(:dossier, procedure: procedure_hier, state: Dossier.states.fetch(:sans_suite), archived: false) }
|
||||
let!(:dossier9) { create(:dossier, procedure: procedure_aujourdhui, state: Dossier.states.fetch(:en_construction), archived: false) }
|
||||
|
||||
before do
|
||||
subject
|
||||
|
@ -37,15 +37,15 @@ RSpec.describe AutoArchiveProcedureJob, type: :job do
|
|||
procedure_aujourdhui.reload
|
||||
end
|
||||
|
||||
it { expect(dossier1.state).to eq 'brouillon' }
|
||||
it { expect(dossier2.state).to eq 'en_instruction' }
|
||||
it { expect(dossier3.state).to eq 'en_instruction' }
|
||||
it { expect(dossier4.state).to eq 'en_instruction' }
|
||||
it { expect(dossier5.state).to eq 'en_instruction' }
|
||||
it { expect(dossier6.state).to eq 'accepte' }
|
||||
it { expect(dossier7.state).to eq 'refuse' }
|
||||
it { expect(dossier8.state).to eq 'sans_suite' }
|
||||
it { expect(dossier9.state).to eq 'en_instruction' }
|
||||
it { expect(dossier1.state).to eq Dossier.states.fetch(:brouillon) }
|
||||
it { expect(dossier2.state).to eq Dossier.states.fetch(:en_instruction) }
|
||||
it { expect(dossier3.state).to eq Dossier.states.fetch(:en_instruction) }
|
||||
it { expect(dossier4.state).to eq Dossier.states.fetch(:en_instruction) }
|
||||
it { expect(dossier5.state).to eq Dossier.states.fetch(:en_instruction) }
|
||||
it { expect(dossier6.state).to eq Dossier.states.fetch(:accepte) }
|
||||
it { expect(dossier7.state).to eq Dossier.states.fetch(:refuse) }
|
||||
it { expect(dossier8.state).to eq Dossier.states.fetch(:sans_suite) }
|
||||
it { expect(dossier9.state).to eq Dossier.states.fetch(:en_instruction) }
|
||||
|
||||
it { expect(procedure_hier.archivee?).to eq true }
|
||||
it { expect(procedure_aujourdhui.archivee?).to eq true }
|
||||
|
|
|
@ -17,7 +17,7 @@ RSpec.describe AutoReceiveDossiersForProcedureJob, type: :job do
|
|||
let(:procedure_id) { dossier_brouillon.procedure_id }
|
||||
|
||||
context "en_construction" do
|
||||
let(:state) { 'en_instruction' }
|
||||
let(:state) { Dossier.states.fetch(:en_instruction) }
|
||||
|
||||
it do
|
||||
subject
|
||||
|
@ -36,7 +36,7 @@ RSpec.describe AutoReceiveDossiersForProcedureJob, type: :job do
|
|||
end
|
||||
|
||||
context "accepte" do
|
||||
let(:state) { 'accepte' }
|
||||
let(:state) { Dossier.states.fetch(:accepte) }
|
||||
|
||||
it do
|
||||
subject
|
||||
|
|
|
@ -2,7 +2,7 @@ describe TagsSubstitutionConcern, type: :model do
|
|||
let(:types_de_champ) { [] }
|
||||
let(:types_de_champ_private) { [] }
|
||||
let(:for_individual) { false }
|
||||
let(:state) { 'accepte' }
|
||||
let(:state) { Dossier.states.fetch(:accepte) }
|
||||
|
||||
let(:procedure) do
|
||||
create(:procedure,
|
||||
|
@ -136,7 +136,7 @@ describe TagsSubstitutionConcern, type: :model do
|
|||
end
|
||||
|
||||
context 'when the dossier is en construction' do
|
||||
let(:state) { 'en_construction' }
|
||||
let(:state) { Dossier.states.fetch(:en_construction) }
|
||||
let(:template) { '--libelleA--' }
|
||||
|
||||
context 'champs privés are not valid tags' do
|
||||
|
@ -251,7 +251,7 @@ describe TagsSubstitutionConcern, type: :model do
|
|||
context 'when generating a document for a dossier that is not termine' do
|
||||
let(:dossier) { create(:dossier) }
|
||||
let(:template) { '--motivation-- --date de décision--' }
|
||||
let(:state) { 'en_instruction' }
|
||||
let(:state) { Dossier.states.fetch(:en_instruction) }
|
||||
|
||||
subject { template_concern.replace_tags(template, dossier) }
|
||||
|
||||
|
@ -275,7 +275,7 @@ describe TagsSubstitutionConcern, type: :model do
|
|||
end
|
||||
|
||||
context 'when generating a document for a dossier en instruction' do
|
||||
let(:state) { 'en_instruction' }
|
||||
let(:state) { Dossier.states.fetch(:en_instruction) }
|
||||
|
||||
it { is_expected.not_to include(include({ libelle: 'motivation' })) }
|
||||
it { is_expected.not_to include(include({ libelle: 'date de décision' })) }
|
||||
|
@ -285,7 +285,7 @@ describe TagsSubstitutionConcern, type: :model do
|
|||
end
|
||||
|
||||
context 'when generating a document for a dossier en construction' do
|
||||
let(:state) { 'en_construction' }
|
||||
let(:state) { Dossier.states.fetch(:en_construction) }
|
||||
|
||||
it { is_expected.not_to include(include({ libelle: 'motivation' })) }
|
||||
it { is_expected.not_to include(include({ libelle: 'date de décision' })) }
|
||||
|
|
|
@ -134,7 +134,7 @@ describe Dossier do
|
|||
|
||||
it 'does not create default champs' do
|
||||
expect(subject).not_to receive(:build_default_champs)
|
||||
subject.update(state: 'en_construction')
|
||||
subject.update(state: Dossier.states.fetch(:en_construction))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -235,7 +235,7 @@ describe Dossier do
|
|||
it { expect(subject[2]).to be_a_kind_of(Time) }
|
||||
it { expect(subject[3]).to be_in([true, false]) }
|
||||
it { expect(subject[4]).to eq(dossier.user.email) }
|
||||
it { expect(subject[5]).to eq("brouillon") }
|
||||
it { expect(subject[5]).to eq(Dossier.states.fetch(:brouillon)) }
|
||||
it { expect(subject[6]).to eq(date1) }
|
||||
it { expect(subject[7]).to eq(date2) }
|
||||
it { expect(subject[8]).to eq(date3) }
|
||||
|
@ -273,7 +273,7 @@ describe Dossier do
|
|||
dossier.updated_at,
|
||||
"false",
|
||||
dossier.user.email,
|
||||
"brouillon",
|
||||
Dossier.states.fetch(:brouillon),
|
||||
dossier.en_construction_at,
|
||||
dossier.en_instruction_at,
|
||||
dossier.processed_at,
|
||||
|
@ -396,7 +396,7 @@ describe Dossier do
|
|||
let(:procedure) { create(:procedure, libelle: "Procédure", organisation: "Organisme") }
|
||||
|
||||
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 }
|
||||
let(:dossier) { create :dossier, procedure: procedure, state: Dossier.states.fetch(:en_construction), en_construction_at: "31/12/2010".to_date }
|
||||
|
||||
subject { dossier.text_summary }
|
||||
|
||||
|
@ -404,7 +404,7 @@ describe Dossier do
|
|||
end
|
||||
|
||||
context 'when the dossier has not been en_construction' do
|
||||
let(:dossier) { create :dossier, procedure: procedure, state: 'brouillon' }
|
||||
let(:dossier) { create :dossier, procedure: procedure, state: Dossier.states.fetch(:brouillon) }
|
||||
|
||||
subject { dossier.text_summary }
|
||||
|
||||
|
@ -414,7 +414,7 @@ describe Dossier do
|
|||
|
||||
describe '#avis_for' do
|
||||
let!(:procedure) { create(:procedure, :published) }
|
||||
let!(:dossier) { create(:dossier, procedure: procedure, state: :en_construction) }
|
||||
let!(:dossier) { create(:dossier, procedure: procedure, state: Dossier.states.fetch(:en_construction)) }
|
||||
|
||||
let!(:gestionnaire) { create(:gestionnaire, procedures: [procedure]) }
|
||||
let!(:expert_1) { create(:gestionnaire) }
|
||||
|
@ -463,7 +463,7 @@ describe Dossier do
|
|||
end
|
||||
|
||||
describe '#update_state_dates' do
|
||||
let(:state) { 'brouillon' }
|
||||
let(:state) { Dossier.states.fetch(:brouillon) }
|
||||
let(:dossier) { create(:dossier, state: state) }
|
||||
let(:beginning_of_day) { Time.now.beginning_of_day }
|
||||
|
||||
|
@ -476,7 +476,7 @@ describe Dossier do
|
|||
dossier.reload
|
||||
end
|
||||
|
||||
it { expect(dossier.state).to eq('en_construction') }
|
||||
it { expect(dossier.state).to eq(Dossier.states.fetch(:en_construction)) }
|
||||
it { expect(dossier.en_construction_at).to eq(beginning_of_day) }
|
||||
|
||||
it 'should keep first en_construction_at date' do
|
||||
|
@ -489,14 +489,14 @@ describe Dossier do
|
|||
end
|
||||
|
||||
context 'when dossier is en_instruction' do
|
||||
let(:state) { 'en_construction' }
|
||||
let(:state) { Dossier.states.fetch(:en_construction) }
|
||||
|
||||
before do
|
||||
dossier.en_instruction!
|
||||
dossier.reload
|
||||
end
|
||||
|
||||
it { expect(dossier.state).to eq('en_instruction') }
|
||||
it { expect(dossier.state).to eq(Dossier.states.fetch(:en_instruction)) }
|
||||
it { expect(dossier.en_instruction_at).to eq(beginning_of_day) }
|
||||
|
||||
it 'should keep first en_instruction_at date if dossier is set to en_construction again' do
|
||||
|
@ -519,30 +519,30 @@ describe Dossier do
|
|||
end
|
||||
|
||||
context 'when dossier is accepte' do
|
||||
let(:state) { 'en_instruction' }
|
||||
let(:state) { Dossier.states.fetch(:en_instruction) }
|
||||
|
||||
it_behaves_like 'dossier is processed', 'accepte'
|
||||
it_behaves_like 'dossier is processed', Dossier.states.fetch(:accepte)
|
||||
end
|
||||
|
||||
context 'when dossier is refuse' do
|
||||
let(:state) { 'en_instruction' }
|
||||
let(:state) { Dossier.states.fetch(:en_instruction) }
|
||||
|
||||
it_behaves_like 'dossier is processed', 'refuse'
|
||||
it_behaves_like 'dossier is processed', Dossier.states.fetch(:refuse)
|
||||
end
|
||||
|
||||
context 'when dossier is sans_suite' do
|
||||
let(:state) { 'en_instruction' }
|
||||
let(:state) { Dossier.states.fetch(:en_instruction) }
|
||||
|
||||
it_behaves_like 'dossier is processed', 'sans_suite'
|
||||
it_behaves_like 'dossier is processed', Dossier.states.fetch(:sans_suite)
|
||||
end
|
||||
end
|
||||
|
||||
describe '.downloadable_sorted' do
|
||||
let(:procedure) { create(:procedure) }
|
||||
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: :en_instruction, en_construction_at: DateTime.parse('01/01/2010')) }
|
||||
let!(:dossier4) { create(:dossier, :with_entreprise, procedure: procedure, state: :en_instruction, archived: true, en_construction_at: DateTime.parse('02/01/2010')) }
|
||||
let!(:dossier) { create(:dossier, :with_entreprise, procedure: procedure, state: Dossier.states.fetch(:brouillon)) }
|
||||
let!(:dossier2) { create(:dossier, :with_entreprise, procedure: procedure, state: Dossier.states.fetch(:en_construction), en_construction_at: DateTime.parse('03/01/2010')) }
|
||||
let!(:dossier3) { create(:dossier, :with_entreprise, procedure: procedure, state: Dossier.states.fetch(:en_instruction), en_construction_at: DateTime.parse('01/01/2010')) }
|
||||
let!(:dossier4) { create(:dossier, :with_entreprise, procedure: procedure, state: Dossier.states.fetch(:en_instruction), archived: true, en_construction_at: DateTime.parse('02/01/2010')) }
|
||||
|
||||
subject { procedure.dossiers.downloadable_sorted }
|
||||
|
||||
|
@ -551,7 +551,7 @@ describe Dossier do
|
|||
|
||||
describe "#send_dossier_received" do
|
||||
let(:procedure) { create(:procedure) }
|
||||
let(:dossier) { create(:dossier, procedure: procedure, state: :en_construction) }
|
||||
let(:dossier) { create(:dossier, procedure: procedure, state: Dossier.states.fetch(:en_construction)) }
|
||||
|
||||
before do
|
||||
allow(NotificationMailer).to receive(:send_dossier_received).and_return(double(deliver_later: nil))
|
||||
|
@ -583,7 +583,7 @@ describe Dossier do
|
|||
ActiveJob::Base.queue_adapter = :test
|
||||
expect do
|
||||
perform_enqueued_jobs do
|
||||
dossier = Dossier.create(procedure: procedure, state: "brouillon", user: user)
|
||||
dossier = Dossier.create(procedure: procedure, state: Dossier.states.fetch(:brouillon), user: user)
|
||||
end
|
||||
end.to change(ActionMailer::Base.deliveries, :size).from(0).to(1)
|
||||
|
||||
|
@ -593,17 +593,17 @@ describe Dossier do
|
|||
end
|
||||
|
||||
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: "en_instruction", user: user) }.not_to change(ActionMailer::Base.deliveries, :size)
|
||||
expect { Dossier.create(procedure: procedure, state: "accepte", user: user) }.not_to change(ActionMailer::Base.deliveries, :size)
|
||||
expect { Dossier.create(procedure: procedure, state: "refuse", user: user) }.not_to change(ActionMailer::Base.deliveries, :size)
|
||||
expect { Dossier.create(procedure: procedure, state: "sans_suite", user: user) }.not_to change(ActionMailer::Base.deliveries, :size)
|
||||
expect { Dossier.create(procedure: procedure, state: Dossier.states.fetch(:en_construction), user: user) }.not_to change(ActionMailer::Base.deliveries, :size)
|
||||
expect { Dossier.create(procedure: procedure, state: Dossier.states.fetch(:en_instruction), user: user) }.not_to change(ActionMailer::Base.deliveries, :size)
|
||||
expect { Dossier.create(procedure: procedure, state: Dossier.states.fetch(:accepte), user: user) }.not_to change(ActionMailer::Base.deliveries, :size)
|
||||
expect { Dossier.create(procedure: procedure, state: Dossier.states.fetch(:refuse), user: user) }.not_to change(ActionMailer::Base.deliveries, :size)
|
||||
expect { Dossier.create(procedure: procedure, state: Dossier.states.fetch(:sans_suite), user: user) }.not_to change(ActionMailer::Base.deliveries, :size)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#unspecified_attestation_champs" do
|
||||
let(:procedure) { create(:procedure, attestation_template: attestation_template) }
|
||||
let(:dossier) { create(:dossier, procedure: procedure, state: :en_instruction) }
|
||||
let(:dossier) { create(:dossier, procedure: procedure, state: Dossier.states.fetch(:en_instruction)) }
|
||||
|
||||
subject { dossier.unspecified_attestation_champs.map(&:libelle) }
|
||||
|
||||
|
@ -669,7 +669,7 @@ describe Dossier do
|
|||
end
|
||||
|
||||
context 'when the dossier is in en_instruction state ' do
|
||||
let!(:dossier) { create(:dossier, procedure: procedure, state: :en_instruction) }
|
||||
let!(:dossier) { create(:dossier, procedure: procedure, state: Dossier.states.fetch(:en_instruction)) }
|
||||
|
||||
context 'when the procedure has no attestation' do
|
||||
it { expect(dossier.attestation).to be_nil }
|
||||
|
@ -942,7 +942,7 @@ describe Dossier do
|
|||
subject { dossier.can_transition_to_en_construction? }
|
||||
|
||||
context "dossier state is brouillon" do
|
||||
let(:state) { "brouillon" }
|
||||
let(:state) { Dossier.states.fetch(:brouillon) }
|
||||
it { is_expected.to be true }
|
||||
|
||||
context "procedure is archived" do
|
||||
|
@ -952,27 +952,27 @@ describe Dossier do
|
|||
end
|
||||
|
||||
context "dossier state is en_construction" do
|
||||
let(:state) { "en_construction" }
|
||||
let(:state) { Dossier.states.fetch(:en_construction) }
|
||||
it { is_expected.to be false }
|
||||
end
|
||||
|
||||
context "dossier state is en_instruction" do
|
||||
let(:state) { "en_instruction" }
|
||||
let(:state) { Dossier.states.fetch(:en_instruction) }
|
||||
it { is_expected.to be false }
|
||||
end
|
||||
|
||||
context "dossier state is en_instruction" do
|
||||
let(:state) { "accepte" }
|
||||
let(:state) { Dossier.states.fetch(:accepte) }
|
||||
it { is_expected.to be false }
|
||||
end
|
||||
|
||||
context "dossier state is en_instruction" do
|
||||
let(:state) { "refuse" }
|
||||
let(:state) { Dossier.states.fetch(:refuse) }
|
||||
it { is_expected.to be false }
|
||||
end
|
||||
|
||||
context "dossier state is en_instruction" do
|
||||
let(:state) { "sans_suite" }
|
||||
let(:state) { Dossier.states.fetch(:sans_suite) }
|
||||
it { is_expected.to be false }
|
||||
end
|
||||
end
|
||||
|
|
|
@ -178,7 +178,7 @@ describe Gestionnaire, type: :model do
|
|||
subject{ gestionnaire.can_view_dossier?(dossier.id) }
|
||||
|
||||
context 'when gestionnaire is assigned on dossier' do
|
||||
let!(:dossier){ create(:dossier, procedure: procedure, state: 'en_instruction') }
|
||||
let!(:dossier){ create(:dossier, procedure: procedure, state: Dossier.states.fetch(:en_instruction)) }
|
||||
|
||||
it { expect(subject).to be true }
|
||||
end
|
||||
|
@ -205,7 +205,7 @@ describe Gestionnaire, type: :model do
|
|||
end
|
||||
|
||||
describe '#notifications_for_dossier' do
|
||||
let!(:dossier) { create(:dossier, :followed, state: 'en_construction') }
|
||||
let!(:dossier) { create(:dossier, :followed, state: Dossier.states.fetch(:en_construction)) }
|
||||
let(:gestionnaire) { dossier.follows.first.gestionnaire }
|
||||
|
||||
subject { gestionnaire.notifications_for_dossier(dossier) }
|
||||
|
@ -254,12 +254,12 @@ describe Gestionnaire, type: :model do
|
|||
end
|
||||
|
||||
describe '#notification_for_procedure' do
|
||||
let!(:dossier) { create(:dossier, :followed, state: 'en_construction') }
|
||||
let!(:dossier) { create(:dossier, :followed, state: Dossier.states.fetch(: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: 'en_construction') }
|
||||
let!(:dossier_on_procedure_2) { create(:dossier, :followed, state: Dossier.states.fetch(:en_construction)) }
|
||||
let!(:gestionnaire_on_procedure_2) { dossier_on_procedure_2.follows.first.gestionnaire }
|
||||
|
||||
before do
|
||||
|
@ -335,7 +335,7 @@ describe Gestionnaire, type: :model do
|
|||
end
|
||||
|
||||
describe '#notifications_per_procedure' do
|
||||
let!(:dossier) { create(:dossier, :followed, state: 'en_construction') }
|
||||
let!(:dossier) { create(:dossier, :followed, state: Dossier.states.fetch(:en_construction)) }
|
||||
let(:gestionnaire) { dossier.follows.first.gestionnaire }
|
||||
let(:procedure) { dossier.procedure }
|
||||
|
||||
|
@ -349,7 +349,7 @@ describe Gestionnaire, type: :model do
|
|||
end
|
||||
|
||||
describe '#mark_tab_as_seen' do
|
||||
let!(:dossier) { create(:dossier, :followed, state: 'en_construction') }
|
||||
let!(:dossier) { create(:dossier, :followed, state: Dossier.states.fetch(:en_construction)) }
|
||||
let(:gestionnaire) { dossier.follows.first.gestionnaire }
|
||||
let(:freeze_date) { DateTime.parse('12/12/2012') }
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ describe ProcedureOverview, type: :model do
|
|||
|
||||
describe 'dossiers_en_instruction_count' do
|
||||
let!(:en_instruction_dossier) do
|
||||
create(:dossier, procedure: procedure, state: :en_instruction, created_at: monday)
|
||||
create(:dossier, procedure: procedure, state: Dossier.states.fetch(:en_instruction), created_at: monday)
|
||||
end
|
||||
|
||||
it { expect(procedure_overview.dossiers_en_instruction_count).to eq(1) }
|
||||
|
@ -20,11 +20,11 @@ describe ProcedureOverview, type: :model do
|
|||
|
||||
describe 'old_dossiers_en_instruction' do
|
||||
let!(:old_dossier_en_instruction) do
|
||||
create(:dossier, procedure: procedure, state: :en_instruction, en_instruction_at: monday - 1.month)
|
||||
create(:dossier, procedure: procedure, state: Dossier.states.fetch(:en_instruction), en_instruction_at: monday - 1.month)
|
||||
end
|
||||
|
||||
let!(:dossier_en_instruction) do
|
||||
create(:dossier, procedure: procedure, state: :en_instruction, en_instruction_at: monday)
|
||||
create(:dossier, procedure: procedure, state: Dossier.states.fetch(:en_instruction), en_instruction_at: monday)
|
||||
end
|
||||
|
||||
it do
|
||||
|
@ -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: :en_construction, created_at: monday)
|
||||
create(:dossier, procedure: procedure, state: Dossier.states.fetch(:en_construction), created_at: monday)
|
||||
end
|
||||
|
||||
it { expect(procedure_overview.dossiers_en_construction_count).to eq(1) }
|
||||
|
@ -42,15 +42,15 @@ describe ProcedureOverview, type: :model do
|
|||
|
||||
describe 'created_dossiers_count' do
|
||||
let!(:created_dossier_during_the_week) do
|
||||
create(:dossier, procedure: procedure, created_at: monday, state: :en_instruction)
|
||||
create(:dossier, procedure: procedure, created_at: monday, state: Dossier.states.fetch(:en_instruction))
|
||||
end
|
||||
|
||||
let!(:created_dossier_during_the_week_but_in_brouillon) do
|
||||
create(:dossier, procedure: procedure, created_at: monday, state: :brouillon)
|
||||
create(:dossier, procedure: procedure, created_at: monday, state: Dossier.states.fetch(:brouillon))
|
||||
end
|
||||
|
||||
let!(:created_dossier_before_the_week) do
|
||||
create(:dossier, procedure: procedure, created_at: (monday - 1.week), state: :en_instruction)
|
||||
create(:dossier, procedure: procedure, created_at: (monday - 1.week), state: Dossier.states.fetch(:en_instruction))
|
||||
end
|
||||
|
||||
it { expect(procedure_overview.created_dossiers_count).to eq(1) }
|
||||
|
|
|
@ -509,9 +509,9 @@ describe Procedure do
|
|||
let(:procedure) { create :procedure }
|
||||
|
||||
before do
|
||||
create :dossier, procedure: procedure, state: :en_construction
|
||||
create :dossier, procedure: procedure, state: :brouillon
|
||||
create :dossier, procedure: procedure, state: :en_construction
|
||||
create :dossier, procedure: procedure, state: Dossier.states.fetch(:en_construction)
|
||||
create :dossier, procedure: procedure, state: Dossier.states.fetch(:brouillon)
|
||||
create :dossier, procedure: procedure, state: Dossier.states.fetch(:en_construction)
|
||||
end
|
||||
|
||||
subject { procedure.total_dossier }
|
||||
|
@ -533,8 +533,8 @@ describe Procedure do
|
|||
end
|
||||
|
||||
context 'when there are some dossiers' do
|
||||
let!(:dossier){ create(:dossier, procedure: procedure, state: 'en_construction') }
|
||||
let!(:dossier2){ create(:dossier, procedure: procedure, state: 'accepte') }
|
||||
let!(:dossier){ create(:dossier, procedure: procedure, state: Dossier.states.fetch(:en_construction)) }
|
||||
let!(:dossier2){ create(:dossier, procedure: procedure, state: Dossier.states.fetch(:accepte)) }
|
||||
|
||||
it { expect(subject[:data].size).to eq(2) }
|
||||
it { expect(subject[:headers]).to eq(dossier.export_headers) }
|
||||
|
@ -574,7 +574,7 @@ describe Procedure do
|
|||
end
|
||||
|
||||
context 'when there is a brouillon dossier' do
|
||||
let!(:dossier_not_exportable){ create(:dossier, procedure: procedure, state: 'brouillon') }
|
||||
let!(:dossier_not_exportable){ create(:dossier, procedure: procedure, state: Dossier.states.fetch(:brouillon)) }
|
||||
|
||||
it_behaves_like "export is empty"
|
||||
end
|
||||
|
|
|
@ -17,19 +17,19 @@ describe DossierSerializer do
|
|||
end
|
||||
|
||||
context 'when the dossier is accepte' do
|
||||
let(:dossier) { create(:dossier, state: :accepte) }
|
||||
let(:dossier) { create(:dossier, state: Dossier.states.fetch(:accepte)) }
|
||||
|
||||
it { is_expected.to include(state: 'closed') }
|
||||
end
|
||||
|
||||
context 'when the dossier is refuse' do
|
||||
let(:dossier) { create(:dossier, state: :refuse) }
|
||||
let(:dossier) { create(:dossier, state: Dossier.states.fetch(:refuse)) }
|
||||
|
||||
it { is_expected.to include(state: 'refused') }
|
||||
end
|
||||
|
||||
context 'when the dossier is sans_suite' do
|
||||
let(:dossier) { create(:dossier, state: :sans_suite) }
|
||||
let(:dossier) { create(:dossier, state: Dossier.states.fetch(:sans_suite)) }
|
||||
|
||||
it { is_expected.to include(state: 'without_continuation') }
|
||||
end
|
||||
|
|
|
@ -19,19 +19,19 @@ describe DossierTableExportSerializer do
|
|||
end
|
||||
|
||||
context 'when the dossier is accepte' do
|
||||
let(:dossier) { create(:dossier, state: :accepte) }
|
||||
let(:dossier) { create(:dossier, state: Dossier.states.fetch(:accepte)) }
|
||||
|
||||
it { is_expected.to include(state: 'closed') }
|
||||
end
|
||||
|
||||
context 'when the dossier is refuse' do
|
||||
let(:dossier) { create(:dossier, state: :refuse) }
|
||||
let(:dossier) { create(:dossier, state: Dossier.states.fetch(:refuse)) }
|
||||
|
||||
it { is_expected.to include(state: 'refused') }
|
||||
end
|
||||
|
||||
context 'when the dossier is sans_suite' do
|
||||
let(:dossier) { create(:dossier, state: :sans_suite) }
|
||||
let(:dossier) { create(:dossier, state: Dossier.states.fetch(:sans_suite)) }
|
||||
|
||||
it { is_expected.to include(state: 'without_continuation') }
|
||||
end
|
||||
|
|
|
@ -22,18 +22,18 @@ describe DossierSearchService 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: 'brouillon', procedure: procedure_1, user: create(:user, email: 'brouillon@clap.fr')) }
|
||||
let!(:dossier_0) { create(:dossier, state: Dossier.states.fetch(:brouillon), procedure: procedure_1, user: create(:user, email: 'brouillon@clap.fr')) }
|
||||
|
||||
let!(:etablissement_1) { create(:etablissement, entreprise_raison_sociale: 'OCTO Academy', siret: '41636169600051') }
|
||||
let!(:dossier_1) { create(:dossier, state: 'en_construction', procedure: procedure_1, user: create(:user, email: 'contact@test.com'), etablissement: etablissement_1) }
|
||||
let!(:dossier_1) { create(:dossier, state: Dossier.states.fetch(:en_construction), procedure: procedure_1, user: create(:user, email: 'contact@test.com'), etablissement: etablissement_1) }
|
||||
|
||||
let!(:etablissement_2) { create(:etablissement, entreprise_raison_sociale: 'Plop octo', siret: '41816602300012') }
|
||||
let!(:dossier_2) { create(:dossier, state: 'en_construction', procedure: procedure_1, user: create(:user, email: 'plop@gmail.com'), etablissement: etablissement_2) }
|
||||
let!(:dossier_2) { create(:dossier, state: Dossier.states.fetch(:en_construction), procedure: procedure_1, user: create(:user, email: 'plop@gmail.com'), etablissement: etablissement_2) }
|
||||
|
||||
let!(:etablissement_3) { create(:etablissement, entreprise_raison_sociale: 'OCTO Technology', siret: '41816609600051') }
|
||||
let!(:dossier_3) { create(:dossier, state: 'en_construction', procedure: procedure_2, user: create(:user, email: 'peace@clap.fr'), etablissement: etablissement_3) }
|
||||
let!(:dossier_3) { create(:dossier, state: Dossier.states.fetch(:en_construction), procedure: procedure_2, user: create(:user, email: 'peace@clap.fr'), etablissement: etablissement_3) }
|
||||
|
||||
let!(:dossier_archived) { create(:dossier, state: 'en_construction', procedure: procedure_1, archived: true, user: create(:user, email: 'brouillonArchived@clap.fr')) }
|
||||
let!(:dossier_archived) { create(:dossier, state: Dossier.states.fetch(:en_construction), procedure: procedure_1, archived: true, user: create(:user, email: 'brouillonArchived@clap.fr')) }
|
||||
|
||||
describe 'search is empty' do
|
||||
let(:terms) { '' }
|
||||
|
|
|
@ -14,17 +14,17 @@ describe UserRoutesAuthorizationService do
|
|||
let(:controller) { Users::DossiersController }
|
||||
|
||||
describe 'brouillon' do
|
||||
let(:state) { 'brouillon' }
|
||||
let(:state) { Dossier.states.fetch(:brouillon) }
|
||||
it { is_expected.to be_truthy }
|
||||
end
|
||||
|
||||
describe 'en_construction' do
|
||||
let(:state) { 'en_construction' }
|
||||
let(:state) { Dossier.states.fetch(:en_construction) }
|
||||
it { is_expected.to be_falsey }
|
||||
end
|
||||
|
||||
describe 'accepte' do
|
||||
let(:state) { 'accepte' }
|
||||
let(:state) { Dossier.states.fetch(:accepte) }
|
||||
it { is_expected.to be_falsey }
|
||||
end
|
||||
end
|
||||
|
@ -34,17 +34,17 @@ describe UserRoutesAuthorizationService do
|
|||
|
||||
context 'when use_api_carto is false' do
|
||||
describe 'brouillon' do
|
||||
let(:state) { 'brouillon' }
|
||||
let(:state) { Dossier.states.fetch(:brouillon) }
|
||||
it { is_expected.to be_falsey }
|
||||
end
|
||||
|
||||
describe 'en_construction' do
|
||||
let(:state) { 'en_construction' }
|
||||
let(:state) { Dossier.states.fetch(:en_construction) }
|
||||
it { is_expected.to be_falsey }
|
||||
end
|
||||
|
||||
describe 'accepte' do
|
||||
let(:state) { 'accepte' }
|
||||
let(:state) { Dossier.states.fetch(:accepte) }
|
||||
it { is_expected.to be_falsey }
|
||||
end
|
||||
end
|
||||
|
@ -53,17 +53,17 @@ describe UserRoutesAuthorizationService do
|
|||
let(:use_api_carto) { true }
|
||||
|
||||
describe 'brouillon' do
|
||||
let(:state) { 'brouillon' }
|
||||
let(:state) { Dossier.states.fetch(:brouillon) }
|
||||
it { is_expected.to be_truthy }
|
||||
end
|
||||
|
||||
describe 'en_construction' do
|
||||
let(:state) { 'en_construction' }
|
||||
let(:state) { Dossier.states.fetch(:en_construction) }
|
||||
it { is_expected.to be_truthy }
|
||||
end
|
||||
|
||||
describe 'accepte' do
|
||||
let(:state) { 'accepte' }
|
||||
let(:state) { Dossier.states.fetch(:accepte) }
|
||||
it { is_expected.to be_falsey }
|
||||
end
|
||||
end
|
||||
|
@ -73,17 +73,17 @@ describe UserRoutesAuthorizationService do
|
|||
let(:controller) { Users::RecapitulatifController }
|
||||
|
||||
describe 'brouillon' do
|
||||
let(:state) { 'brouillon' }
|
||||
let(:state) { Dossier.states.fetch(:brouillon) }
|
||||
it { is_expected.to be_falsey }
|
||||
end
|
||||
|
||||
describe 'en_construction' do
|
||||
let(:state) { 'en_construction' }
|
||||
let(:state) { Dossier.states.fetch(:en_construction) }
|
||||
it { is_expected.to be_truthy }
|
||||
end
|
||||
|
||||
describe 'accepte' do
|
||||
let(:state) { 'accepte' }
|
||||
let(:state) { Dossier.states.fetch(:accepte) }
|
||||
it { is_expected.to be_truthy }
|
||||
end
|
||||
end
|
||||
|
|
|
@ -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) { 'brouillon' }
|
||||
let(:state) { Dossier.states.fetch(:brouillon) }
|
||||
|
||||
before do
|
||||
sign_in dossier.user
|
||||
|
@ -12,7 +12,7 @@ describe 'layouts/left_panels/_left_panel_users_recapitulatifcontroller_show.htm
|
|||
|
||||
context 'buttons to change dossier state' do
|
||||
context 'when dossier state is en_construction' do
|
||||
let(:state) { 'en_construction' }
|
||||
let(:state) { Dossier.states.fetch(:en_construction) }
|
||||
before do
|
||||
render
|
||||
end
|
||||
|
@ -21,7 +21,7 @@ describe 'layouts/left_panels/_left_panel_users_recapitulatifcontroller_show.htm
|
|||
end
|
||||
|
||||
context 'when dossier state is accepte' do
|
||||
let(:state) { 'accepte' }
|
||||
let(:state) { Dossier.states.fetch(:accepte) }
|
||||
|
||||
before do
|
||||
render
|
||||
|
@ -35,7 +35,7 @@ describe 'layouts/left_panels/_left_panel_users_recapitulatifcontroller_show.htm
|
|||
end
|
||||
|
||||
context 'when dossier state is refuse' do
|
||||
let(:state) { 'refuse' }
|
||||
let(:state) { Dossier.states.fetch(:refuse) }
|
||||
|
||||
before do
|
||||
render
|
||||
|
@ -49,7 +49,7 @@ describe 'layouts/left_panels/_left_panel_users_recapitulatifcontroller_show.htm
|
|||
end
|
||||
|
||||
context 'when dossier state is sans_suite' do
|
||||
let(:state) { 'sans_suite' }
|
||||
let(:state) { Dossier.states.fetch(:sans_suite) }
|
||||
|
||||
before do
|
||||
render
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'new_user/dossiers/identite.html.haml', type: :view do
|
||||
let(:dossier) { create(:dossier, :with_entreprise, :with_service, state: 'brouillon', procedure: create(:procedure, :with_api_carto, :with_two_type_de_piece_justificative, for_individual: true)) }
|
||||
let(:dossier) { create(:dossier, :with_entreprise, :with_service, state: Dossier.states.fetch(:brouillon), procedure: create(:procedure, :with_api_carto, :with_two_type_de_piece_justificative, for_individual: true)) }
|
||||
let(:footer) { view.content_for(:footer) }
|
||||
|
||||
before do
|
||||
|
|
|
@ -2,8 +2,8 @@ require 'spec_helper'
|
|||
|
||||
describe 'new_user/dossiers/index.html.haml', type: :view do
|
||||
let(:user) { create(:user) }
|
||||
let(:dossier_brouillon) { create(:dossier, state: 'brouillon', user: user) }
|
||||
let(:dossier_en_construction) { create(:dossier, state: 'en_construction', user: user) }
|
||||
let(:dossier_brouillon) { create(:dossier, state: Dossier.states.fetch(:brouillon), user: user) }
|
||||
let(:dossier_en_construction) { create(:dossier, state: Dossier.states.fetch(:en_construction), user: user) }
|
||||
let(:user_dossiers) { [dossier_brouillon, dossier_en_construction] }
|
||||
let(:dossiers_invites) { [] }
|
||||
let(:current_tab) { 'mes-dossiers' }
|
||||
|
|
|
@ -2,7 +2,7 @@ require 'spec_helper'
|
|||
|
||||
describe 'new_user/dossiers/modifier.html.haml', type: :view do
|
||||
let(:procedure) { create(:procedure, :with_api_carto, :with_two_type_de_piece_justificative, :with_notice, for_individual: true) }
|
||||
let(:dossier) { create(:dossier, :with_entreprise, :with_service, state: 'brouillon', procedure: procedure) }
|
||||
let(:dossier) { create(:dossier, :with_entreprise, :with_service, state: Dossier.states.fetch(:brouillon), procedure: procedure) }
|
||||
let(:footer) { view.content_for(:footer) }
|
||||
|
||||
before do
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'users/carte/show.html.haml', type: :view do
|
||||
let(:state) { 'brouillon' }
|
||||
let(:state) { Dossier.states.fetch(:brouillon) }
|
||||
let(:dossier) { create(:dossier, state: state) }
|
||||
let(:dossier_id) { dossier.id }
|
||||
|
||||
|
@ -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) { 'en_construction' }
|
||||
let(:state) { Dossier.states.fetch(:en_construction) }
|
||||
|
||||
it 'le bouton "Etape suivante" n\'est pas présent' do
|
||||
expect(rendered).to_not have_selector('#etape_suivante')
|
||||
|
|
|
@ -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) { 'brouillon' }
|
||||
let(:state) { Dossier.states.fetch(:brouillon) }
|
||||
|
||||
before do
|
||||
sign_in dossier.user
|
||||
|
@ -60,7 +60,7 @@ describe 'users/recapitulatif/show.html.haml', type: :view do
|
|||
end
|
||||
|
||||
context 'when dossier state is en_construction' do
|
||||
let(:state) { 'en_construction' }
|
||||
let(:state) { Dossier.states.fetch(:en_construction) }
|
||||
before do
|
||||
render
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue