Merge pull request #2474 from betagouv/improve-enums

Improve enums
This commit is contained in:
gregoirenovel 2018-08-29 17:37:21 +02:00 committed by GitHub
commit feb5105b18
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
80 changed files with 333 additions and 333 deletions

View file

@ -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

View file

@ -42,7 +42,7 @@ class FranceConnect::ParticulierController < ApplicationController
sign_in user
user.update_attribute('loged_in_with_france_connect', 'particulier')
user.update_attribute('loged_in_with_france_connect', User.loged_in_with_france_connects.fetch(:particulier))
redirect_to stored_location_for(current_user) || root_path(current_user)
end

View file

@ -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"

View file

@ -26,11 +26,11 @@ class RootController < ApplicationController
.map.with_index { |type_de_champ, i| type_de_champ.champ.build(id: i) }
all_champs
.select { |champ| champ.type_champ == 'header_section' }
.select { |champ| champ.type_champ == TypeDeChamp.type_champs.fetch(:header_section) }
.each { |champ| champ.type_de_champ.libelle = 'un super titre de section' }
all_champs
.select { |champ| %w(drop_down_list multiple_drop_down_list).include?(champ.type_champ) }
.select { |champ| [TypeDeChamp.type_champs.fetch(:drop_down_list), TypeDeChamp.type_champs.fetch(:multiple_drop_down_list)].include?(champ.type_champ) }
.each do |champ|
champ.type_de_champ.drop_down_list = DropDownList.new(type_de_champ: champ.type_de_champ)
champ.drop_down_list.value =
@ -42,9 +42,9 @@ class RootController < ApplicationController
end
type_champ_values = {
'date': '2016-07-26',
'datetime': '26/07/2016 07:35',
'textarea': 'Une description de mon projet'
TypeDeChamp.type_champs.fetch(:date) => '2016-07-26',
TypeDeChamp.type_champs.fetch(:datetime) => '26/07/2016 07:35',
TypeDeChamp.type_champs.fetch(:textarea) => 'Une description de mon projet'
}
type_champ_values.each do |(type_champ, value)|

View file

@ -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)

View file

@ -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?

View file

@ -49,7 +49,7 @@ class Users::SessionsController < Sessions::SessionsController
sign_out :user
case connected_with_france_connect
when 'particulier'
when User.loged_in_with_france_connects.fetch(:particulier)
redirect_to FRANCE_CONNECT[:particulier][:logout_endpoint]
return
end

View file

@ -2,17 +2,17 @@ class ChampDecorator < Draper::Decorator
delegate_all
def value
if type_champ == "date" && object.value.present?
if type_champ == TypeDeChamp.type_champs.fetch(:date) && object.value.present?
Date.parse(object.value).strftime("%d/%m/%Y")
elsif type_champ.in? ["checkbox", "engagement"]
elsif type_champ.in? [TypeDeChamp.type_champs.fetch(:checkbox), TypeDeChamp.type_champs.fetch(:engagement)]
object.value == 'on' ? 'Oui' : 'Non'
elsif type_champ == 'yes_no'
elsif type_champ == TypeDeChamp.type_champs.fetch(:yes_no)
if object.value == 'true'
'Oui'
elsif object.value == 'false'
'Non'
end
elsif type_champ == 'multiple_drop_down_list' && object.value.present?
elsif type_champ == TypeDeChamp.type_champs.fetch(:multiple_drop_down_list) && object.value.present?
JSON.parse(object.value).join(', ')
else
object.value
@ -21,9 +21,9 @@ class ChampDecorator < Draper::Decorator
def date_for_input
if object.value.present?
if type_champ == "date"
if type_champ == TypeDeChamp.type_champs.fetch(:date)
object.value
elsif type_champ == "datetime" && object.value != ' 00:00'
elsif type_champ == TypeDeChamp.type_champs.fetch(:datetime) && object.value != ' 00:00'
DateTime.parse(object.value, "%Y-%m-%d %H:%M").strftime("%Y-%m-%d")
end
end

View file

@ -1,6 +1,6 @@
module ChampHelper
def has_label?(champ)
types_without_label = ['header_section', 'explication']
types_without_label = [TypeDeChamp.type_champs.fetch(:header_section), TypeDeChamp.type_champs.fetch(:explication)]
!types_without_label.include?(champ.type_champ)
end
end

View file

@ -1,8 +1,8 @@
module TypeDeChampHelper
TOGGLES = {
'piece_justificative' => :champ_pj?,
'siret' => :champ_siret?,
'linked_drop_down_list' => :champ_linked_dropdown?
TypeDeChamp.type_champs.fetch(:piece_justificative) => :champ_pj?,
TypeDeChamp.type_champs.fetch(:siret) => :champ_siret?,
TypeDeChamp.type_champs.fetch(:linked_drop_down_list) => :champ_linked_dropdown?
}
def tdc_options

View file

@ -9,9 +9,9 @@ class AntiVirusJob < ApplicationJob
if @blob.present?
download_blob_to_tempfile do |file|
if ClamavService.safe_file?(file.path)
status = "safe"
status = VirusScan.statuses.fetch(:safe)
else
status = "infected"
status = VirusScan.statuses.fetch(:infected)
end
virus_scan.update(scanned_at: Time.now, status: status)
end

View file

@ -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
}

View file

@ -19,7 +19,7 @@ class FindDubiousProceduresJob < ApplicationJob
forbidden_tdcs = TypeDeChamp
.joins(:procedure)
.where("unaccent(types_de_champ.libelle) ~* unaccent(?)", forbidden_regexp)
.where(type_champ: %w(text textarea))
.where(type_champ: [TypeDeChamp.type_champs.fetch(:text), TypeDeChamp.type_champs.fetch(:textarea)])
.where(procedures: { archived_at: nil, whitelisted_at: nil })
dubious_procedures_and_tdcs = forbidden_tdcs

View file

@ -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))

View file

@ -54,7 +54,7 @@ class Champs::PieceJustificativeChamp < Champ
if self.piece_justificative_file&.attachment&.blob.present?
VirusScan.where(champ: self).where.not(blob_key: self.piece_justificative_file.blob.key).delete_all
VirusScan.find_or_create_by!(champ: self, blob_key: self.piece_justificative_file.blob.key) do |virus_scan|
virus_scan.status = "pending"
virus_scan.status = VirusScan.statuses.fetch(:pending)
end
end
end

View file

@ -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)]
}
]

View file

@ -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) }

View file

@ -19,6 +19,6 @@ class DropDownList < ApplicationRecord
end
def multiple
type_de_champ.type_champ == 'multiple_drop_down_list'
type_de_champ.type_champ == TypeDeChamp.type_champs.fetch(:multiple_drop_down_list)
end
end

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -323,14 +323,14 @@ class Procedure < ApplicationRecord
end
types_de_champ
.reject { |tdc| ['header_section', 'explication'].include?(tdc.type_champ) }
.reject { |tdc| [TypeDeChamp.type_champs.fetch(:header_section), TypeDeChamp.type_champs.fetch(:explication)].include?(tdc.type_champ) }
.each do |type_de_champ|
fields << field_hash(type_de_champ.libelle, 'type_de_champ', type_de_champ.id.to_s)
end
types_de_champ_private
.reject { |tdc| ['header_section', 'explication'].include?(tdc.type_champ) }
.reject { |tdc| [TypeDeChamp.type_champs.fetch(:header_section), TypeDeChamp.type_champs.fetch(:explication)].include?(tdc.type_champ) }
.each do |type_de_champ|
fields << field_hash(type_de_champ.libelle, 'type_de_champ_private', type_de_champ.id.to_s)

View file

@ -72,7 +72,7 @@ class TypeDeChamp < ApplicationRecord
end
def non_fillable?
type_champ.in?(['header_section', 'explication'])
type_champ.in?([TypeDeChamp.type_champs.fetch(:header_section), TypeDeChamp.type_champs.fetch(:explication)])
end
def public?
@ -86,7 +86,7 @@ class TypeDeChamp < ApplicationRecord
private
def remove_piece_justificative_template
if type_champ != 'piece_justificative' && piece_justificative_template.attached?
if type_champ != TypeDeChamp.type_champs.fetch(:piece_justificative) && piece_justificative_template.attached?
piece_justificative_template.purge_later
end
end

View file

@ -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

View file

@ -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

View file

@ -13,17 +13,17 @@ class ChampsService
def check_piece_justificative_files(champs)
champs.select do |champ|
champ.type_champ == 'piece_justificative'
champ.type_champ == TypeDeChamp.type_champs.fetch(:piece_justificative)
end.map { |c| c.piece_justificative_file_errors }.flatten
end
private
def fill_champs(champs, h)
datetimes, not_datetimes = champs.partition { |c| c.type_champ == 'datetime' }
datetimes, not_datetimes = champs.partition { |c| c.type_champ == TypeDeChamp.type_champs.fetch(:datetime) }
not_datetimes.each do |c|
if c.type_champ == 'piece_justificative' && h["champs"]["'#{c.id}'"].present?
if c.type_champ == TypeDeChamp.type_champs.fetch(:piece_justificative) && h["champs"]["'#{c.id}'"].present?
c.piece_justificative_file.attach(h["champs"]["'#{c.id}'"])
else
c.value = h[:champs]["'#{c.id}'"]

View file

@ -1,7 +1,7 @@
= f.fields_for @types_de_champ_facade.fields_for_var, types_de_champ, remote: true do |ff|
- type_champ = ff.object.object.type_champ
.form-inline{ class: (type_champ == 'header_section' ? 'header-section' : nil) }
.form-inline{ class: (type_champ == TypeDeChamp.type_champs.fetch(:header_section) ? 'header-section' : nil) }
.form-group.libelle
%h4 Libellé
= ff.text_field :libelle, class: 'form-control libelle', placeholder: 'Libellé'
@ -20,9 +20,9 @@
~ fff.text_area :value, class: 'form-control drop_down_list', placeholder: "Ecrire une valeur par ligne et --valeur-- pour un séparateur.", rows: 3, cols: 30
= fff.hidden_field :id
.form-group.pj-template{ class: (type_champ == 'piece_justificative') ? 'show-inline' : nil }
.form-group.pj-template{ class: (type_champ == TypeDeChamp.type_champs.fetch(:piece_justificative)) ? 'show-inline' : nil }
%h4 Modèle
- if type_champ == 'piece_justificative'
- if type_champ == TypeDeChamp.type_champs.fetch(:piece_justificative)
- template = ff.object.object.piece_justificative_template
- if !template.attached?
@ -38,7 +38,7 @@
= ff.file_field :piece_justificative_template,
direct_upload: true
- hide_mandatory = (ff.object.object.private? || type_champ == 'explication')
- hide_mandatory = (ff.object.object.private? || type_champ == TypeDeChamp.type_champs.fetch(:explication))
.form-group.mandatory{ style: hide_mandatory ? 'visibility: hidden;' : nil }
%h4 Obligatoire ?
.center

View file

@ -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

View file

@ -25,8 +25,8 @@
- if @facade.champs.present?
- @facade.champs.each do |champ|
- next if champ.type_champ == 'explication'
- if champ.type_champ == 'header_section'
- next if champ.type_champ == TypeDeChamp.type_champs.fetch(:explication)
- if champ.type_champ == TypeDeChamp.type_champs.fetch(:header_section)
.row.title-row.margin-top-40
.col-xs-3.split-hr
.col-xs-6.dossier-title= champ.libelle
@ -38,7 +38,7 @@
= "-"
.col-xs-5.depositaire-info{ id: "champ-#{champ.id}-value" }
- if champ.decorate.value.present? || champ.piece_justificative_file.attached?
- if champ.type_champ == 'dossier_link'
- if champ.type_champ == TypeDeChamp.type_champs.fetch(:dossier_link)
- dossier = Dossier.includes(:procedure).find_by(id: champ.decorate.value)
- if dossier
= link_to("Dossier #{dossier.id}", modifier_dossier_path(dossier), target: '_blank')
@ -46,11 +46,11 @@
= sanitize(dossier.text_summary)
- else
Pas de dossier associé
- elsif champ.type_champ == 'piece_justificative'
- elsif champ.type_champ == TypeDeChamp.type_champs.fetch(:piece_justificative)
= render partial: "shared/champs/piece_justificative/pj_link", locals: { champ: champ, user_can_upload: true }
- elsif champ.type_champ == 'textarea'
- elsif champ.type_champ == TypeDeChamp.type_champs.fetch(:textarea)
= simple_format(champ.decorate.value)
- elsif champ.type_champ == 'linked_drop_down_list'
- elsif champ.type_champ == TypeDeChamp.type_champs.fetch(:linked_drop_down_list)
= champ.for_display
- else
= sanitize(champ.decorate.value)

View file

@ -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<>

View file

@ -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<>

View file

@ -1,12 +1,12 @@
%table.table.vertical.dossier-champs
%tbody
- champs.reject { |c| c.type_champ == "explication" }.each do |c|
- champs.reject { |c| c.type_champ == TypeDeChamp.type_champs.fetch(:explication) }.each do |c|
%tr
- case c.type_champ
- when "header_section"
- when TypeDeChamp.type_champs.fetch(:header_section)
%th.header-section{ colspan: 3 }
= c.libelle
- when "multiple_drop_down_list"
- when TypeDeChamp.type_champs.fetch(:multiple_drop_down_list)
%th.libelle
= "#{c.libelle} :"
%td.rich-text
@ -15,11 +15,11 @@
- c.value.split(", ").each do |item|
%li
= item
- when "linked_drop_down_list"
- when TypeDeChamp.type_champs.fetch(:linked_drop_down_list)
%th.libelle
= "#{c.libelle} :"
%td= c.for_display
- when "dossier_link"
- when TypeDeChamp.type_champs.fetch(:dossier_link)
%th.libelle
= "#{c.libelle} :"
%td.rich-text
@ -34,7 +34,7 @@
= sanitize(dossier.text_summary)
- else
Pas de dossier associé
- when "piece_justificative"
- when TypeDeChamp.type_champs.fetch(:piece_justificative)
%th.libelle
= "#{c.libelle} :"
%td.rich-text
@ -43,13 +43,13 @@
= render partial: "shared/champs/piece_justificative/pj_link", locals: { champ: c, user_can_upload: false }
- else
Pièce justificative non fournie
- when "textarea"
- when TypeDeChamp.type_champs.fetch(:textarea)
%th.libelle
= "#{c.libelle} :"
%td.rich-text
%span{ class: highlight_if_unseen_class(demande_seen_at, c.updated_at) }
= simple_format(c.value)
- when "siret"
- when TypeDeChamp.type_champs.fetch(:siret)
%th.libelle
= "#{c.libelle} :"
%td.rich-text
@ -62,7 +62,7 @@
%td.rich-text
%span{ class: highlight_if_unseen_class(demande_seen_at, c.updated_at) }
= sanitize(c.value)
- if c.type_champ != "header_section"
- if c.type_champ != TypeDeChamp.type_champs.fetch(:header_section)
%td.updated-at
%span{ class: highlight_if_unseen_class(demande_seen_at, c.updated_at) }
modifié le

View file

@ -32,7 +32,7 @@ describe Admin::TypesDeChampController, type: :controller do
describe '#update' do
let(:libelle) { 'mon libelle' }
let(:type_champ) { 'header_section' }
let(:type_champ) { TypeDeChamp.type_champs.fetch(:header_section) }
let(:description) { 'titi' }
let(:order_place) { '' }
let(:types_de_champ_id) { '' }
@ -74,12 +74,12 @@ describe Admin::TypesDeChampController, type: :controller do
subject { procedure.types_de_champ.first }
it { expect(subject.libelle).to eq('mon libelle') }
it { expect(subject.type_champ).to eq('header_section') }
it { expect(subject.type_champ).to eq(TypeDeChamp.type_champs.fetch(:header_section)) }
it { expect(subject.description).to eq('titi') }
end
context 'when type_champ is header_section and mandatory is true' do
let(:type_champ) { 'header_section' }
let(:type_champ) { TypeDeChamp.type_champs.fetch(:header_section) }
let(:mandatory) { 'on' }
before do
@ -98,7 +98,7 @@ describe Admin::TypesDeChampController, type: :controller do
let(:type_de_champ) { procedure.types_de_champ.first }
let(:types_de_champ_id) { type_de_champ.id }
let(:libelle) { 'toto' }
let(:type_champ) { 'header_section' }
let(:type_champ) { TypeDeChamp.type_champs.fetch(:header_section) }
let(:description) { 'citrouille' }
let(:order_place) { '0' }
let(:mandatory) { 'on' }
@ -111,7 +111,7 @@ describe Admin::TypesDeChampController, type: :controller do
subject { procedure.types_de_champ.first }
it { expect(subject.libelle).to eq('toto') }
it { expect(subject.type_champ).to eq('header_section') }
it { expect(subject.type_champ).to eq(TypeDeChamp.type_champs.fetch(:header_section)) }
it { expect(subject.description).to eq('citrouille') }
it { expect(subject.order_place).to eq(0) }
it { expect(subject.order_place).to be_truthy }

View file

@ -32,7 +32,7 @@ describe Admin::TypesDeChampPrivateController, type: :controller do
describe '#update' do
let(:libelle) { 'mon libelle' }
let(:type_champ) { 'text' }
let(:type_champ) { TypeDeChamp.type_champs.fetch(:text) }
let(:description) { 'titi' }
let(:order_place) { '' }
let(:types_de_champ_id) { '' }
@ -84,7 +84,7 @@ describe Admin::TypesDeChampPrivateController, type: :controller do
let(:type_de_champ) { procedure.types_de_champ_private.first }
let(:types_de_champ_id) { type_de_champ.id }
let(:libelle) { 'toto' }
let(:type_champ) { 'text' }
let(:type_champ) { TypeDeChamp.type_champs.fetch(:text) }
let(:description) { 'citrouille' }
let(:order_place) { '0' }
let(:mandatory) { 'on' }
@ -94,7 +94,7 @@ describe Admin::TypesDeChampPrivateController, type: :controller do
end
subject { procedure.types_de_champ_private.first }
it { expect(subject.libelle).to eq('toto') }
it { expect(subject.type_champ).to eq('text') }
it { expect(subject.type_champ).to eq(TypeDeChamp.type_champs.fetch(:text)) }
it { expect(subject.description).to eq('citrouille') }
it { expect(subject.order_place).to eq(0) }
it { expect(subject.order_place).to be_truthy }

View file

@ -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)

View file

@ -53,7 +53,7 @@ describe FranceConnect::ParticulierController, type: :controller do
it do
subject
expect(user.reload.loged_in_with_france_connect).to eq('particulier')
expect(user.reload.loged_in_with_france_connect).to eq(User.loged_in_with_france_connects.fetch(:particulier))
end
context 'and the user has a stored location' do

View file

@ -30,7 +30,7 @@ describe NewAdministrateur::ServicesController, type: :controller do
it { expect(Service.last.nom).to eq('super service') }
it { expect(Service.last.organisme).to eq('organisme') }
it { expect(Service.last.siret).to eq('01234567891234') }
it { expect(Service.last.type_organisme).to eq('region') }
it { expect(Service.last.type_organisme).to eq(Service.type_organismes.fetch(:region)) }
it { expect(Service.last.email).to eq('email@toto.com') }
it { expect(Service.last.telephone).to eq('1234') }
it { expect(Service.last.horaires).to eq('horaires') }
@ -48,7 +48,7 @@ describe NewAdministrateur::ServicesController, type: :controller do
describe '#update' do
let!(:service) { create(:service, administrateur: admin) }
let(:service_params) { { nom: 'nom', type_organisme: 'region' } }
let(:service_params) { { nom: 'nom', type_organisme: Service.type_organismes.fetch(:region) } }
before do
sign_in admin
@ -64,12 +64,12 @@ describe NewAdministrateur::ServicesController, type: :controller do
it { expect(flash.alert).to be_nil }
it { expect(flash.notice).to eq('nom modifié') }
it { expect(Service.last.nom).to eq('nom') }
it { expect(Service.last.type_organisme).to eq('region') }
it { expect(Service.last.type_organisme).to eq(Service.type_organismes.fetch(:region)) }
it { expect(response).to redirect_to(services_path(procedure_id: procedure.id)) }
end
context 'when updating a service with invalid data' do
let(:service_params) { { nom: '', type_organisme: 'region' } }
let(:service_params) { { nom: '', type_organisme: Service.type_organismes.fetch(:region) } }
it { expect(flash.alert).not_to be_nil }
it { expect(response).to render_template(:edit) }

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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) }

View file

@ -4,7 +4,7 @@ shared_examples 'carte_controller_spec' do
context 'when dossiers 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

View file

@ -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) }

View file

@ -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 } }

View file

@ -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

View file

@ -1,7 +1,7 @@
require 'spec_helper'
describe Users::SessionsController, type: :controller do
let(:loged_in_with_france_connect) { 'particulier' }
let(:loged_in_with_france_connect) { User.loged_in_with_france_connects.fetch(:particulier) }
let(:user) { create(:user, loged_in_with_france_connect: loged_in_with_france_connect) }
before do
@ -115,7 +115,7 @@ describe Users::SessionsController, type: :controller do
end
context 'when user is connect with france connect particulier' do
let(:loged_in_with_france_connect) { 'particulier' }
let(:loged_in_with_france_connect) { User.loged_in_with_france_connects.fetch(:particulier) }
it 'redirect to france connect logout page' do
expect(response).to redirect_to(FRANCE_CONNECT[:particulier][:logout_endpoint])
@ -158,7 +158,7 @@ describe Users::SessionsController, type: :controller do
end
it 'signs user out from france connect' do
user.update(loged_in_with_france_connect: 'particulier')
user.update(loged_in_with_france_connect: User.loged_in_with_france_connects.fetch(:particulier))
sign_in user
delete :destroy
expect(@response.headers["Location"]).to eq(FRANCE_CONNECT[:particulier][:logout_endpoint])

View file

@ -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

View file

@ -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|
@ -56,7 +56,7 @@ FactoryBot.define do
trait :with_dossier_link do
after(:create) do |dossier, _evaluator|
linked_dossier = create(:dossier)
type_de_champ = dossier.procedure.types_de_champ.find { |t| t.type_champ == 'dossier_link' }
type_de_champ = dossier.procedure.types_de_champ.find { |t| t.type_champ == TypeDeChamp.type_champs.fetch(:dossier_link) }
champ = dossier.champs.find { |c| c.type_de_champ == type_de_champ }
champ.value = linked_dossier.id
@ -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)
'Lentreprise concernée nest pas agréée.'
when 'sans_suite'
when Dossier.states.fetch(:sans_suite)
'Le département nest pas éligible. Veuillez remplir un nouveau dossier auprès de la DDT du 93.'
else
'Vous avez validé les conditions.'

View file

@ -2,7 +2,7 @@ FactoryBot.define do
factory :service do
nom 'service'
organisme 'organisme'
type_organisme 'commune'
type_organisme Service.type_organismes.fetch(:commune)
administrateur { create(:administrateur) }
email 'email@toto.com'
telephone '1234'

View file

@ -3,84 +3,84 @@ FactoryBot.define do
private false
sequence(:libelle) { |n| "Libelle du champ #{n}" }
sequence(:description) { |n| "description du champ #{n}" }
type_champ 'text'
type_champ TypeDeChamp.type_champs.fetch(:text)
order_place 1
mandatory false
factory :type_de_champ_text, class: 'TypesDeChamp::TextTypeDeChamp' do
type_champ 'text'
type_champ TypeDeChamp.type_champs.fetch(:text)
end
factory :type_de_champ_textarea, class: 'TypesDeChamp::TextareaTypeDeChamp' do
type_champ 'textarea'
type_champ TypeDeChamp.type_champs.fetch(:textarea)
end
factory :type_de_champ_number, class: 'TypesDeChamp::NumberTypeDeChamp' do
type_champ 'number'
type_champ TypeDeChamp.type_champs.fetch(:number)
end
factory :type_de_champ_checkbox, class: 'TypesDeChamp::CheckboxTypeDeChamp' do
type_champ 'checkbox'
type_champ TypeDeChamp.type_champs.fetch(:checkbox)
end
factory :type_de_champ_civilite, class: 'TypesDeChamp::CiviliteTypeDeChamp' do
type_champ 'civilite'
type_champ TypeDeChamp.type_champs.fetch(:civilite)
end
factory :type_de_champ_email, class: 'TypesDeChamp::EmailTypeDeChamp' do
type_champ 'email'
type_champ TypeDeChamp.type_champs.fetch(:email)
end
factory :type_de_champ_phone, class: 'TypesDeChamp::PhoneTypeDeChamp' do
type_champ 'phone'
type_champ TypeDeChamp.type_champs.fetch(:phone)
end
factory :type_de_champ_address, class: 'TypesDeChamp::AddressTypeDeChamp' do
type_champ 'address'
type_champ TypeDeChamp.type_champs.fetch(:address)
end
factory :type_de_champ_yes_no, class: 'TypesDeChamp::YesNoTypeDeChamp' do
libelle 'Yes/no'
type_champ 'yes_no'
type_champ TypeDeChamp.type_champs.fetch(:yes_no)
end
factory :type_de_champ_date, class: 'TypesDeChamp::DateTypeDeChamp' do
type_champ 'date'
type_champ TypeDeChamp.type_champs.fetch(:date)
end
factory :type_de_champ_datetime, class: 'TypesDeChamp::DatetimeTypeDeChamp' do
type_champ 'datetime'
type_champ TypeDeChamp.type_champs.fetch(:datetime)
end
factory :type_de_champ_drop_down_list, class: 'TypesDeChamp::DropDownListTypeDeChamp' do
libelle 'Menu déroulant'
type_champ 'drop_down_list'
type_champ TypeDeChamp.type_champs.fetch(:drop_down_list)
drop_down_list { create(:drop_down_list) }
end
factory :type_de_champ_multiple_drop_down_list, class: 'TypesDeChamp::MultipleDropDownListTypeDeChamp' do
type_champ 'multiple_drop_down_list'
type_champ TypeDeChamp.type_champs.fetch(:multiple_drop_down_list)
drop_down_list { create(:drop_down_list) }
end
factory :type_de_champ_linked_drop_down_list, class: 'TypesDeChamp::LinkedDropDownListTypeDeChamp' do
type_champ 'linked_drop_down_list'
type_champ TypeDeChamp.type_champs.fetch(:linked_drop_down_list)
drop_down_list { create(:drop_down_list) }
end
factory :type_de_champ_pays, class: 'TypesDeChamp::PaysTypeDeChamp' do
type_champ 'pays'
type_champ TypeDeChamp.type_champs.fetch(:pays)
end
factory :type_de_champ_regions, class: 'TypesDeChamp::RegionTypeDeChamp' do
type_champ 'regions'
type_champ TypeDeChamp.type_champs.fetch(:regions)
end
factory :type_de_champ_departements, class: 'TypesDeChamp::DepartementTypeDeChamp' do
type_champ 'departements'
type_champ TypeDeChamp.type_champs.fetch(:departements)
end
factory :type_de_champ_engagement, class: 'TypesDeChamp::EngagementTypeDeChamp' do
type_champ 'engagement'
type_champ TypeDeChamp.type_champs.fetch(:engagement)
end
factory :type_de_champ_header_section, class: 'TypesDeChamp::HeaderSectionTypeDeChamp' do
type_champ 'header_section'
type_champ TypeDeChamp.type_champs.fetch(:header_section)
end
factory :type_de_champ_explication, class: 'TypesDeChamp::ExplicationTypeDeChamp' do
type_champ 'explication'
type_champ TypeDeChamp.type_champs.fetch(:explication)
end
factory :type_de_champ_dossier_link, class: 'TypesDeChamp::DossierLinkTypeDeChamp' do
libelle 'Référence autre dossier'
type_champ 'dossier_link'
type_champ TypeDeChamp.type_champs.fetch(:dossier_link)
end
factory :type_de_champ_piece_justificative, class: 'TypesDeChamp::PieceJustificativeTypeDeChamp' do
type_champ 'piece_justificative'
type_champ TypeDeChamp.type_champs.fetch(:piece_justificative)
end
factory :type_de_champ_siret, class: 'TypesDeChamp::SiretTypeDeChamp' do
type_champ 'siret'
type_champ TypeDeChamp.type_champs.fetch(:siret)
end
trait :private do

View file

@ -18,7 +18,7 @@ feature 'add a new type de champs', js: true do
context 'user fill a new type de champ', js: true do
let(:libelle) { 'mon libelle' }
let(:type_champ) { 'text' }
let(:type_champ) { TypeDeChamp.type_champs.fetch(:text) }
let(:description) { 'ma super histoire' }
before do
page.find_by_id('procedure_types_de_champ_attributes_0_libelle').set libelle
@ -39,7 +39,7 @@ feature 'add a new type de champs', js: true do
context 'user fill another one' do
let(:libelle) { 'coucou' }
let(:type_champ_value) { 'textarea' }
let(:type_champ_value) { TypeDeChamp.type_champs.fetch(:textarea) }
let(:type_champ_label) { 'Zone de texte' }
let(:description) { 'to be or not to be' }
before do

View file

@ -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

View file

@ -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")

View file

@ -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)

View file

@ -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

View file

@ -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 }

View file

@ -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

View file

@ -2,7 +2,7 @@ require 'rails_helper'
RSpec.describe TypeDeChampHelper, type: :helper do
describe ".tdc_options" do
let(:pj_option) { ["Pièce justificative", "piece_justificative"] }
let(:pj_option) { ["Pièce justificative", TypeDeChamp.type_champs.fetch(:piece_justificative)] }
subject { tdc_options }

View file

@ -4,7 +4,7 @@ RSpec.describe AntiVirusJob, type: :job do
champ.piece_justificative_file.attach(io: StringIO.new("toto"), filename: "toto.txt", content_type: "text/plain")
champ
end
let(:virus_scan) { create(:virus_scan, status: "pending", champ: champ, blob_key: champ.piece_justificative_file.blob.key) }
let(:virus_scan) { create(:virus_scan, status: VirusScan.statuses.fetch(:pending), champ: champ, blob_key: champ.piece_justificative_file.blob.key) }
subject { AntiVirusJob.new.perform(virus_scan) }
@ -16,7 +16,7 @@ RSpec.describe AntiVirusJob, type: :job do
subject
end
it { expect(virus_scan.reload.status).to eq("safe") }
it { expect(virus_scan.reload.status).to eq(VirusScan.statuses.fetch(:safe)) }
end
context "when a virus is found" do
@ -27,6 +27,6 @@ RSpec.describe AntiVirusJob, type: :job do
subject
end
it { expect(virus_scan.reload.status).to eq("infected") }
it { expect(virus_scan.reload.status).to eq(VirusScan.statuses.fetch(:infected)) }
end
end

View file

@ -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 }

View file

@ -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

View file

@ -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
@ -160,8 +160,8 @@ describe TagsSubstitutionConcern, type: :model do
context 'when the procedure has 2 types de champ date and datetime' do
let(:types_de_champ) do
[
create(:type_de_champ_date, libelle: 'date'),
create(:type_de_champ_datetime, libelle: 'datetime')
create(:type_de_champ_date, libelle: TypeDeChamp.type_champs.fetch(:date)),
create(:type_de_champ_datetime, libelle: TypeDeChamp.type_champs.fetch(:datetime))
]
end
@ -171,12 +171,12 @@ describe TagsSubstitutionConcern, type: :model do
context 'and its value in the dossier are not nil' do
before do
dossier.champs
.select { |champ| champ.type_champ == 'date' }
.select { |champ| champ.type_champ == TypeDeChamp.type_champs.fetch(:date) }
.first
.update(value: '2017-04-15')
dossier.champs
.select { |champ| champ.type_champ == 'datetime' }
.select { |champ| champ.type_champ == TypeDeChamp.type_champs.fetch(:datetime) }
.first
.update(value: '2017-09-13 09:00')
end
@ -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' })) }

View file

@ -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

View file

@ -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') }

View file

@ -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) }

View file

@ -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
@ -659,10 +659,10 @@ describe Procedure do
}
before do
subject.types_de_champ[2].update_attribute(:type_champ, 'header_section')
subject.types_de_champ[3].update_attribute(:type_champ, 'explication')
subject.types_de_champ_private[2].update_attribute(:type_champ, 'header_section')
subject.types_de_champ_private[3].update_attribute(:type_champ, 'explication')
subject.types_de_champ[2].update_attribute(:type_champ,TypeDeChamp.type_champs.fetch(:header_section))
subject.types_de_champ[3].update_attribute(:type_champ,TypeDeChamp.type_champs.fetch(:explication))
subject.types_de_champ_private[2].update_attribute(:type_champ,TypeDeChamp.type_champs.fetch(:header_section))
subject.types_de_champ_private[3].update_attribute(:type_champ,TypeDeChamp.type_champs.fetch(:explication))
end
it { expect(subject.fields).to eq(expected) }

View file

@ -5,7 +5,7 @@ describe Service, type: :model do
{
nom: 'service des jardins',
organisme: 'mairie des iles',
type_organisme: 'commune',
type_organisme: Service.type_organismes.fetch(:commune),
email: 'super@email.com',
telephone: '1212202',
horaires: 'du lundi au vendredi',

View file

@ -10,11 +10,11 @@ shared_examples 'type_de_champ_spec' do
it { is_expected.not_to allow_value(nil).for(:type_champ) }
it { is_expected.not_to allow_value('').for(:type_champ) }
it { is_expected.to allow_value('text').for(:type_champ) }
it { is_expected.to allow_value('textarea').for(:type_champ) }
it { is_expected.to allow_value('datetime').for(:type_champ) }
it { is_expected.to allow_value('number').for(:type_champ) }
it { is_expected.to allow_value('checkbox').for(:type_champ) }
it { is_expected.to allow_value(TypeDeChamp.type_champs.fetch(:text)).for(:type_champ) }
it { is_expected.to allow_value(TypeDeChamp.type_champs.fetch(:textarea)).for(:type_champ) }
it { is_expected.to allow_value(TypeDeChamp.type_champs.fetch(:datetime)).for(:type_champ) }
it { is_expected.to allow_value(TypeDeChamp.type_champs.fetch(:number)).for(:type_champ) }
it { is_expected.to allow_value(TypeDeChamp.type_champs.fetch(:checkbox)).for(:type_champ) }
it do
TypeDeChamp.type_champs.each do |(type_champ, _)|
@ -53,7 +53,7 @@ shared_examples 'type_de_champ_spec' do
end
context 'when the target type_champ is not pj' do
let(:target_type_champ) { 'text' }
let(:target_type_champ) { TypeDeChamp.type_champs.fetch(:text) }
context 'calls template.purge_later when a file is attached' do
let(:attached) { true }
@ -69,7 +69,7 @@ shared_examples 'type_de_champ_spec' do
end
context 'when the target type_champ is pj' do
let(:target_type_champ) { 'piece_justificative' }
let(:target_type_champ) { TypeDeChamp.type_champs.fetch(:piece_justificative) }
context 'does not call template.purge_later when a file is attached' do
let(:attached) { true }

View file

@ -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

View file

@ -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

View file

@ -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) { '' }

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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' }

View file

@ -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

View file

@ -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')

View file

@ -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