Rename demarche archivée to demarche close
This commit is contained in:
parent
143a8c7c55
commit
7b947feae4
40 changed files with 140 additions and 138 deletions
|
@ -19,7 +19,7 @@ class Admin::ProceduresController < AdminController
|
|||
|
||||
def archived
|
||||
@procedures = smart_listing_create :procedures,
|
||||
current_administrateur.procedures.archivees.order(published_at: :desc),
|
||||
current_administrateur.procedures.closes.order(published_at: :desc),
|
||||
partial: "admin/procedures/list",
|
||||
array: true
|
||||
|
||||
|
@ -52,7 +52,7 @@ class Admin::ProceduresController < AdminController
|
|||
def destroy
|
||||
procedure = current_administrateur.procedures.find(params[:id])
|
||||
|
||||
if procedure.publiee_ou_archivee?
|
||||
if procedure.publiee_ou_close?
|
||||
return render json: {}, status: 401
|
||||
end
|
||||
|
||||
|
@ -95,9 +95,9 @@ class Admin::ProceduresController < AdminController
|
|||
|
||||
def archive
|
||||
procedure = current_administrateur.procedures.find(params[:procedure_id])
|
||||
procedure.archive!
|
||||
procedure.close!
|
||||
|
||||
flash.notice = "Démarche archivée"
|
||||
flash.notice = "Démarche close"
|
||||
redirect_to admin_procedures_path
|
||||
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
|
@ -131,7 +131,7 @@ class Admin::ProceduresController < AdminController
|
|||
|
||||
def new_from_existing
|
||||
significant_procedure_ids = Procedure
|
||||
.publiees_ou_archivees
|
||||
.publiees_ou_closes
|
||||
.joins(:dossiers)
|
||||
.group("procedures.id")
|
||||
.having("count(dossiers.id) >= ?", SIGNIFICANT_DOSSIERS_THRESHOLD)
|
||||
|
|
|
@ -285,7 +285,7 @@ class ApplicationController < ActionController::Base
|
|||
DS_ID: current_administrateur&.id,
|
||||
DS_NB_DEMARCHES_BROUILLONS: nb_demarches_by_state['brouillon'],
|
||||
DS_NB_DEMARCHES_ACTIVES: nb_demarches_by_state['publiee'],
|
||||
DS_NB_DEMARCHES_ARCHIVES: nb_demarches_by_state['archivee']
|
||||
DS_NB_DEMARCHES_ARCHIVES: nb_demarches_by_state['close']
|
||||
}
|
||||
}
|
||||
end
|
||||
|
|
|
@ -10,7 +10,7 @@ module Instructeurs
|
|||
.procedures
|
||||
.with_attached_logo
|
||||
.includes(:defaut_groupe_instructeur)
|
||||
.order(archived_at: :desc, published_at: :desc, created_at: :desc)
|
||||
.order(closed_at: :desc, archived_at: :desc, published_at: :desc, created_at: :desc)
|
||||
|
||||
dossiers = current_instructeur.dossiers.joins(:groupe_instructeur)
|
||||
@dossiers_count_per_procedure = dossiers.all_state.group('groupe_instructeurs.procedure_id').reorder(nil).count
|
||||
|
|
|
@ -4,7 +4,7 @@ class StatsController < ApplicationController
|
|||
MEAN_NUMBER_OF_CHAMPS_IN_A_FORM = 24.0
|
||||
|
||||
def index
|
||||
procedures = Procedure.publiees_ou_archivees
|
||||
procedures = Procedure.publiees_ou_closes
|
||||
dossiers = Dossier.state_not_brouillon
|
||||
|
||||
@procedures_numbers = procedures_numbers(procedures)
|
||||
|
|
|
@ -53,7 +53,7 @@ module Users
|
|||
def procedure_not_found
|
||||
procedure = Procedure.find_by(path: params[:path])
|
||||
|
||||
if procedure&.archivee?
|
||||
if procedure&.close?
|
||||
flash.alert = t('errors.messages.procedure_archived')
|
||||
else
|
||||
flash.alert = t('errors.messages.procedure_not_found')
|
||||
|
|
|
@ -26,7 +26,7 @@ class ProcedureDashboard < Administrate::BaseDashboard
|
|||
auto_archive_on: Field::DateTime,
|
||||
published_at: Field::DateTime,
|
||||
hidden_at: Field::DateTime,
|
||||
archived_at: Field::DateTime,
|
||||
closed_at: Field::DateTime,
|
||||
whitelisted_at: Field::DateTime,
|
||||
service: Field::BelongsTo,
|
||||
initiated_mail_template: MailTemplateField,
|
||||
|
@ -68,7 +68,7 @@ class ProcedureDashboard < Administrate::BaseDashboard
|
|||
:published_at,
|
||||
:whitelisted_at,
|
||||
:hidden_at,
|
||||
:archived_at,
|
||||
:closed_at,
|
||||
:types_de_champ,
|
||||
:types_de_champ_private,
|
||||
:for_individual,
|
||||
|
|
|
@ -253,16 +253,16 @@ type Demarche {
|
|||
}
|
||||
|
||||
enum DemarcheState {
|
||||
"""
|
||||
Archivée
|
||||
"""
|
||||
archivee
|
||||
|
||||
"""
|
||||
Brouillon
|
||||
"""
|
||||
brouillon
|
||||
|
||||
"""
|
||||
Close
|
||||
"""
|
||||
close
|
||||
|
||||
"""
|
||||
Publiée
|
||||
"""
|
||||
|
|
|
@ -17,7 +17,7 @@ module Types
|
|||
field :date_creation, GraphQL::Types::ISO8601DateTime, "Date de la création.", null: false, method: :created_at
|
||||
field :date_publication, GraphQL::Types::ISO8601DateTime, "Date de la publication.", null: false, method: :published_at
|
||||
field :date_derniere_modification, GraphQL::Types::ISO8601DateTime, "Date de la dernière modification.", null: false, method: :updated_at
|
||||
field :date_fermeture, GraphQL::Types::ISO8601DateTime, "Date de la fermeture.", null: true, method: :archived_at
|
||||
field :date_fermeture, GraphQL::Types::ISO8601DateTime, "Date de la fermeture.", null: true, method: :closed_at
|
||||
|
||||
field :groupe_instructeurs, [Types::GroupeInstructeurType], null: false
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ module DossierHelper
|
|||
end
|
||||
|
||||
def dossier_submission_is_closed?(dossier)
|
||||
dossier.brouillon? && dossier.procedure.archivee?
|
||||
dossier.brouillon? && dossier.procedure.close?
|
||||
end
|
||||
|
||||
def dossier_display_state(dossier, lower: false)
|
||||
|
|
|
@ -14,7 +14,7 @@ module ProcedureHelper
|
|||
end
|
||||
|
||||
def procedure_modal_text(procedure, key)
|
||||
action = procedure.archivee? ? :reopen : :publish
|
||||
action = procedure.close? ? :reopen : :publish
|
||||
t(action, scope: [:modal, :publish, key])
|
||||
end
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ class AutoArchiveProcedureJob < ApplicationJob
|
|||
.state_en_construction
|
||||
.find_each(&:passer_automatiquement_en_instruction!)
|
||||
|
||||
procedure.archive!
|
||||
procedure.close!
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -20,7 +20,7 @@ class FindDubiousProceduresJob < ApplicationJob
|
|||
.joins(:procedure)
|
||||
.where("unaccent(types_de_champ.libelle) ~* unaccent(?)", forbidden_regexp)
|
||||
.where(type_champ: [TypeDeChamp.type_champs.fetch(:text), TypeDeChamp.type_champs.fetch(:textarea)])
|
||||
.where(procedures: { archived_at: nil, whitelisted_at: nil })
|
||||
.where(procedures: { closed_at: nil, whitelisted_at: nil })
|
||||
|
||||
dubious_procedures_and_tdcs = forbidden_tdcs
|
||||
.group_by(&:procedure_id)
|
||||
|
|
|
@ -14,7 +14,7 @@ class Administrateur < ApplicationRecord
|
|||
before_validation -> { sanitize_email(:email) }
|
||||
|
||||
scope :inactive, -> { joins(:user).where(users: { last_sign_in_at: nil }) }
|
||||
scope :with_publiees_ou_archivees, -> { joins(:procedures).where(procedures: { aasm_state: [:publiee, :archivee] }) }
|
||||
scope :with_publiees_ou_closes, -> { joins(:procedures).where(procedures: { aasm_state: [:publiee, :archivee, :close] }) }
|
||||
|
||||
# validate :password_complexity, if: Proc.new { |a| Devise.password_length.include?(a.password.try(:size)) }
|
||||
|
||||
|
|
|
@ -257,7 +257,7 @@ class Dossier < ApplicationRecord
|
|||
end
|
||||
|
||||
def can_transition_to_en_construction?
|
||||
!procedure.archivee? && brouillon?
|
||||
!procedure.close? && brouillon?
|
||||
end
|
||||
|
||||
def can_be_updated_by_user?
|
||||
|
|
|
@ -46,8 +46,8 @@ class Procedure < ApplicationRecord
|
|||
default_scope { where(hidden_at: nil) }
|
||||
scope :brouillons, -> { where(aasm_state: :brouillon) }
|
||||
scope :publiees, -> { where(aasm_state: :publiee) }
|
||||
scope :archivees, -> { where(aasm_state: :archivee) }
|
||||
scope :publiees_ou_archivees, -> { where(aasm_state: [:publiee, :archivee]) }
|
||||
scope :closes, -> { where(aasm_state: [:archivee, :close]) }
|
||||
scope :publiees_ou_closes, -> { where(aasm_state: [:publiee, :close, :archivee]) }
|
||||
scope :by_libelle, -> { order(libelle: :asc) }
|
||||
scope :created_during, -> (range) { where(created_at: range) }
|
||||
scope :cloned_from_library, -> { where(cloned_from_library: true) }
|
||||
|
@ -77,7 +77,7 @@ class Procedure < ApplicationRecord
|
|||
validates :lien_site_web, presence: true, if: :publiee?
|
||||
validate :validate_for_publication, on: :publication
|
||||
validate :check_juridique
|
||||
validates :path, presence: true, format: { with: /\A[a-z0-9_\-]{3,50}\z/ }, uniqueness: { scope: [:path, :archived_at, :hidden_at], case_sensitive: false }
|
||||
validates :path, presence: true, format: { with: /\A[a-z0-9_\-]{3,50}\z/ }, uniqueness: { scope: [:path, :closed_at, :archived_at, :hidden_at], case_sensitive: false }
|
||||
# FIXME: remove duree_conservation_required flag once all procedures are converted to the new style
|
||||
validates :duree_conservation_dossiers_dans_ds, allow_nil: false, numericality: { only_integer: true, greater_than_or_equal_to: 1, less_than_or_equal_to: MAX_DUREE_CONSERVATION }, if: :durees_conservation_required
|
||||
validates :duree_conservation_dossiers_hors_ds, allow_nil: false, numericality: { only_integer: true, greater_than_or_equal_to: 0 }, if: :durees_conservation_required
|
||||
|
@ -95,22 +95,22 @@ class Procedure < ApplicationRecord
|
|||
aasm whiny_persistence: true do
|
||||
state :brouillon, initial: true
|
||||
state :publiee
|
||||
state :archivee
|
||||
state :close
|
||||
state :hidden
|
||||
|
||||
event :publish, before: :before_publish, after: :after_publish do
|
||||
transitions from: :brouillon, to: :publiee
|
||||
transitions from: :archivee, to: :publiee
|
||||
transitions from: :close, to: :publiee
|
||||
end
|
||||
|
||||
event :archive, after: :after_archive do
|
||||
transitions from: :publiee, to: :archivee
|
||||
event :close, after: :after_close do
|
||||
transitions from: :publiee, to: :close
|
||||
end
|
||||
|
||||
event :hide, after: :after_hide do
|
||||
transitions from: :brouillon, to: :hidden
|
||||
transitions from: :publiee, to: :hidden
|
||||
transitions from: :archivee, to: :hidden
|
||||
transitions from: :close, to: :hidden
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -122,7 +122,7 @@ class Procedure < ApplicationRecord
|
|||
|
||||
other_procedure = other_procedure_with_path(path)
|
||||
if other_procedure.present? && administrateur.owns?(other_procedure)
|
||||
other_procedure.archive!
|
||||
other_procedure.close!
|
||||
end
|
||||
|
||||
publish!
|
||||
|
@ -227,9 +227,10 @@ class Procedure < ApplicationRecord
|
|||
end
|
||||
|
||||
def validate_for_publication
|
||||
old_attributes = self.slice(:aasm_state, :archived_at)
|
||||
old_attributes = self.slice(:aasm_state, :archived_at, :closed_at)
|
||||
self.aasm_state = :publiee
|
||||
self.archived_at = nil
|
||||
self.closed_at = nil
|
||||
|
||||
is_valid = validate
|
||||
|
||||
|
@ -272,16 +273,24 @@ class Procedure < ApplicationRecord
|
|||
update(csv_export_queued: false, xlsx_export_queued: false, ods_export_queued: false)
|
||||
end
|
||||
|
||||
def closed_at
|
||||
read_attribute(:closed_at).presence || archived_at
|
||||
end
|
||||
|
||||
def close?
|
||||
aasm_state == 'close' || aasm_state == 'archivee'
|
||||
end
|
||||
|
||||
def locked?
|
||||
publiee_ou_archivee?
|
||||
publiee_ou_close?
|
||||
end
|
||||
|
||||
def accepts_new_dossiers?
|
||||
!archivee?
|
||||
!close?
|
||||
end
|
||||
|
||||
def publiee_ou_archivee?
|
||||
publiee? || archivee?
|
||||
def publiee_ou_close?
|
||||
publiee? || close?
|
||||
end
|
||||
|
||||
def expose_legacy_carto_api?
|
||||
|
@ -363,6 +372,7 @@ class Procedure < ApplicationRecord
|
|||
procedure.path = SecureRandom.uuid
|
||||
procedure.aasm_state = :brouillon
|
||||
procedure.archived_at = nil
|
||||
procedure.closed_at = nil
|
||||
procedure.published_at = nil
|
||||
procedure.lien_notice = nil
|
||||
|
||||
|
@ -599,15 +609,16 @@ class Procedure < ApplicationRecord
|
|||
end
|
||||
|
||||
def before_publish
|
||||
update!(archived_at: nil)
|
||||
update!(archived_at: nil, closed_at: nil)
|
||||
end
|
||||
|
||||
def after_publish
|
||||
update!(published_at: Time.zone.now)
|
||||
end
|
||||
|
||||
def after_archive
|
||||
update!(archived_at: Time.zone.now)
|
||||
def after_close
|
||||
now = Time.zone.now
|
||||
update!(archived_at: now, closed_at: now)
|
||||
purge_export_files
|
||||
end
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ class ProcedureSerializer < ActiveModel::Serializer
|
|||
belongs_to :service, serializer: ServiceSerializer
|
||||
|
||||
def archived_at
|
||||
object.archived_at&.in_time_zone('UTC')
|
||||
object.closed_at&.in_time_zone('UTC')
|
||||
end
|
||||
|
||||
def link
|
||||
|
@ -32,7 +32,8 @@ class ProcedureSerializer < ActiveModel::Serializer
|
|||
end
|
||||
|
||||
def state
|
||||
object.aasm_state
|
||||
state = object.aasm_state
|
||||
state == 'close' ? 'archivee' : state
|
||||
end
|
||||
|
||||
def geographic_information
|
||||
|
|
|
@ -35,7 +35,7 @@ class AdministrateurUsageStatisticsService
|
|||
nb_instructeurs: nb_instructeurs_by_administrateur_id[administrateur.id],
|
||||
|
||||
ds_nb_demarches_actives: nb_demarches_by_administrateur_id_and_state[[administrateur.id, "publiee"]],
|
||||
ds_nb_demarches_archives: nb_demarches_by_administrateur_id_and_state[[administrateur.id, "archivee"]],
|
||||
ds_nb_demarches_archives: nb_demarches_by_administrateur_id_and_state[[administrateur.id, "close"]],
|
||||
ds_nb_demarches_brouillons: nb_demarches_by_administrateur_id_and_state[[administrateur.id, "brouillon"]],
|
||||
|
||||
nb_demarches_test: nb_dossiers_by_procedure_id
|
||||
|
|
|
@ -19,13 +19,13 @@
|
|||
%td.col-xs-6= link_to(procedure.libelle, admin_procedure_href)
|
||||
- if procedure.publiee?
|
||||
%td.procedure-lien= link_to(procedure_lien(procedure), procedure_lien(procedure))
|
||||
- if procedure.publiee_ou_archivee?
|
||||
- if procedure.publiee_ou_close?
|
||||
%td= link_to(procedure.published_at.present? ? try_format_datetime(procedure.published_at) : "", admin_procedure_href)
|
||||
- else
|
||||
%td= link_to(try_format_datetime(procedure.created_at), admin_procedure_href)
|
||||
%td
|
||||
= link_to('Cloner', admin_procedure_clone_path(procedure.id), data: { method: :put }, class: 'btn-sm btn-primary clone-btn')
|
||||
- if !procedure.publiee_ou_archivee?
|
||||
- if !procedure.publiee_ou_close?
|
||||
= link_to('X', url_for(controller: 'admin/procedures', action: :destroy, id: procedure.id), data: { method: :delete, confirm: "Confirmez-vous la suppression de la démarche ? \n\n Attention : toute suppression est définitive et s’appliquera aux éventuels autres administrateurs de cette démarche !" }, class: 'btn-sm btn-danger')
|
||||
|
||||
= smart_listing.paginate
|
||||
|
|
|
@ -13,5 +13,5 @@
|
|||
%li{ class: @archived_class }
|
||||
%a{ :href => "#{url_for :admin_procedures_archived}" }
|
||||
%h5{ style: 'color: black;' }
|
||||
Archivées
|
||||
Closes
|
||||
%br
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
%i.fa.fa-exchange
|
||||
Envoyer une copie
|
||||
|
||||
- if @procedure.archivee?
|
||||
- if @procedure.close?
|
||||
%a.btn.btn-default#reopen-procedure{ data: { target: '#publish-modal', toggle: :modal }, type: 'button', style: 'float: right; margin-top: 10px; margin-right: 10px;' }
|
||||
%i.fa.fa-rocket
|
||||
Réactiver
|
||||
|
@ -49,8 +49,8 @@
|
|||
- else
|
||||
Publication
|
||||
%div{ style: 'margin-top: 30px;' }
|
||||
- if @procedure.archivee?
|
||||
Cette démarche est <strong>archivée</strong> et n’est donc plus accessible par le public.
|
||||
- if @procedure.close?
|
||||
Cette démarche est <strong>close</strong> et n’est donc plus accessible par le public.
|
||||
- elsif @procedure.publiee?
|
||||
Cette démarche est <strong>publiée</strong>, certains éléments ne peuvent plus être modifiés.
|
||||
Pour y accéder vous pouvez utiliser le lien :
|
||||
|
|
|
@ -61,6 +61,6 @@
|
|||
.stats-legend
|
||||
= t('pluralize.archived', count: archived_count)
|
||||
|
||||
- if p.archivee?
|
||||
- if p.close?
|
||||
.procedure-status
|
||||
%span.label Archivée
|
||||
%span.label Close
|
||||
|
|
|
@ -23,9 +23,9 @@
|
|||
|
||||
%a#archived-procedures{ :href => "#{url_for :admin_procedures_archived}" }
|
||||
.procedure-list-element{ class: @archived_class }
|
||||
Archivées
|
||||
Closes
|
||||
.badge.progress-bar-purple
|
||||
= current_administrateur.procedures.archivees.count
|
||||
= current_administrateur.procedures.closes.count
|
||||
|
||||
.split-hr-left
|
||||
= render partial: 'layouts/switch_devise_profile_module'
|
||||
|
|
|
@ -141,7 +141,7 @@
|
|||
%ul.numbers
|
||||
%li.number
|
||||
.number-value
|
||||
= number_with_delimiter(Administrateur.with_publiees_ou_archivees.uniq.count, :locale => :fr)
|
||||
= number_with_delimiter(Administrateur.with_publiees_ou_closes.uniq.count, :locale => :fr)
|
||||
.number-label<
|
||||
administrations
|
||||
%br<>
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
%ul.numbers
|
||||
%li.number
|
||||
.number-value
|
||||
= number_with_delimiter(Procedure.includes(:administrateurs).publiees_ou_archivees.flat_map(&:administrateurs).uniq.count, :locale => :fr)
|
||||
= number_with_delimiter(Procedure.includes(:administrateurs).publiees_ou_closes.flat_map(&:administrateurs).uniq.count, :locale => :fr)
|
||||
.number-label<
|
||||
administrations
|
||||
%br<>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
.card.featured
|
||||
.card-title
|
||||
Le dépôt de dossier est fermé
|
||||
- if dossier.procedure.archived_at.present?
|
||||
Il n'est plus possible de déposer de dossier pour cette démarche en ligne depuis le #{try_format_date(dossier.procedure.archived_at)}.
|
||||
- if dossier.procedure.closed_at.present?
|
||||
Il n'est plus possible de déposer de dossier pour cette démarche en ligne depuis le #{try_format_date(dossier.procedure.closed_at)}.
|
||||
- else
|
||||
Il n'est plus possible de déposer de dossier pour cette démarche en ligne.
|
||||
|
|
|
@ -186,7 +186,7 @@ fr:
|
|||
etablissement_fail: 'Désolé, nous n’avons pas réussi à enregistrer l’établissement correspondant à ce numéro SIRET'
|
||||
france_connect:
|
||||
connexion: "Erreur lors de la connexion à France Connect."
|
||||
procedure_archived: "Cette démarche en ligne a été fermée, il n'est plus possible de déposer de dossier."
|
||||
procedure_archived: "Cette démarche en ligne a été close, il n'est plus possible de déposer de dossier."
|
||||
procedure_not_draft: "Cette démarche n’est maintenant plus en brouillon."
|
||||
cadastres_empty:
|
||||
one: "Aucune parcelle cadastrale sur la zone sélectionnée"
|
||||
|
|
|
@ -12,5 +12,5 @@ fr:
|
|||
duree_conservation_dossiers_hors_ds: Durée de conservation des dossiers hors demarches-simplifiees.fr
|
||||
aasm_state/brouillon: Brouillon
|
||||
aasm_state/publiee: Publiée
|
||||
aasm_state/archivee: Archivée
|
||||
aasm_state/close: Close
|
||||
aasm_state/hidden: Suprimée
|
||||
|
|
|
@ -96,9 +96,9 @@ describe Admin::ProceduresController, type: :controller do
|
|||
end
|
||||
|
||||
describe 'DELETE #destroy' do
|
||||
let(:procedure_draft) { create :procedure_with_dossiers, administrateur: admin, instructeurs: [admin.instructeur], published_at: nil, archived_at: nil }
|
||||
let(:procedure_published) { create :procedure_with_dossiers, administrateur: admin, instructeurs: [admin.instructeur], aasm_state: :publiee, published_at: Time.zone.now, archived_at: nil }
|
||||
let(:procedure_archived) { create :procedure_with_dossiers, administrateur: admin, instructeurs: [admin.instructeur], aasm_state: :archivee, published_at: nil, archived_at: Time.zone.now }
|
||||
let(:procedure_draft) { create :procedure_with_dossiers, administrateur: admin, instructeurs: [admin.instructeur], published_at: nil, closed_at: nil }
|
||||
let(:procedure_published) { create :procedure_with_dossiers, administrateur: admin, instructeurs: [admin.instructeur], aasm_state: :publiee, published_at: Time.zone.now, closed_at: nil }
|
||||
let(:procedure_closed) { create :procedure_with_dossiers, administrateur: admin, instructeurs: [admin.instructeur], aasm_state: :close, published_at: nil, closed_at: Time.zone.now }
|
||||
|
||||
subject { delete :destroy, params: { id: procedure.id } }
|
||||
|
||||
|
@ -129,8 +129,8 @@ describe Admin::ProceduresController, type: :controller do
|
|||
it { expect(subject.status).to eq 401 }
|
||||
end
|
||||
|
||||
context 'when procedure is archived' do
|
||||
let!(:procedure) { procedure_archived }
|
||||
context 'when procedure is closed' do
|
||||
let!(:procedure) { procedure_closed }
|
||||
|
||||
it { expect { subject }.not_to change { Procedure.count } }
|
||||
it { expect { subject }.not_to change { Dossier.count } }
|
||||
|
@ -138,7 +138,7 @@ describe Admin::ProceduresController, type: :controller do
|
|||
end
|
||||
|
||||
context "when administrateur does not own the procedure" do
|
||||
let(:procedure_not_owned) { create :procedure, administrateur: create(:administrateur), published_at: nil, archived_at: nil }
|
||||
let(:procedure_not_owned) { create :procedure, administrateur: create(:administrateur), published_at: nil, closed_at: nil }
|
||||
|
||||
subject { delete :destroy, params: { id: procedure_not_owned.id } }
|
||||
|
||||
|
@ -185,7 +185,7 @@ describe Admin::ProceduresController, type: :controller do
|
|||
end
|
||||
|
||||
it 'archive previous procedure' do
|
||||
expect(procedure2.archivee?).to be_truthy
|
||||
expect(procedure2.close?).to be_truthy
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -201,7 +201,7 @@ describe Admin::ProceduresController, type: :controller do
|
|||
|
||||
it 'previous procedure remains published' do
|
||||
expect(procedure2.publiee?).to be_truthy
|
||||
expect(procedure2.archivee?).to be_falsey
|
||||
expect(procedure2.close?).to be_falsey
|
||||
expect(procedure2.path).to match(/fake_path/)
|
||||
end
|
||||
end
|
||||
|
@ -260,9 +260,9 @@ describe Admin::ProceduresController, type: :controller do
|
|||
end
|
||||
|
||||
context 'when owner want archive procedure' do
|
||||
it { expect(procedure.archivee?).to be_truthy }
|
||||
it { expect(procedure.close?).to be_truthy }
|
||||
it { expect(response).to redirect_to :admin_procedures }
|
||||
it { expect(flash[:notice]).to have_content 'Démarche archivée' }
|
||||
it { expect(flash[:notice]).to have_content 'Démarche close' }
|
||||
end
|
||||
|
||||
context 'when owner want to re-enable procedure' do
|
||||
|
@ -351,16 +351,16 @@ describe Admin::ProceduresController, type: :controller do
|
|||
describe 'selecting' do
|
||||
let!(:large_draft_procedure) { create(:procedure_with_dossiers, dossiers_count: 2) }
|
||||
let!(:large_published_procedure) { create(:procedure_with_dossiers, :published, dossiers_count: 2) }
|
||||
let!(:large_archived_procedure) { create(:procedure_with_dossiers, :archived, dossiers_count: 2) }
|
||||
let!(:small_archived_procedure) { create(:procedure_with_dossiers, :archived, dossiers_count: 1) }
|
||||
let!(:large_closed_procedure) { create(:procedure_with_dossiers, :closed, dossiers_count: 2) }
|
||||
let!(:small_closed_procedure) { create(:procedure_with_dossiers, :closed, dossiers_count: 1) }
|
||||
|
||||
it 'displays published and archived procedures' do
|
||||
it 'displays published and closed procedures' do
|
||||
expect(response_procedures).to include(large_published_procedure)
|
||||
expect(response_procedures).to include(large_archived_procedure)
|
||||
expect(response_procedures).to include(large_closed_procedure)
|
||||
end
|
||||
|
||||
it 'doesn’t display procedures without a significant number of dossiers' do
|
||||
expect(response_procedures).not_to include(small_archived_procedure)
|
||||
expect(response_procedures).not_to include(small_closed_procedure)
|
||||
end
|
||||
|
||||
it 'doesn’t display draft procedures' do
|
||||
|
|
|
@ -35,7 +35,7 @@ describe API::V1::ProceduresController, type: :controller do
|
|||
it { expect(subject[:description]).to eq(procedure.description) }
|
||||
it { expect(subject[:organisation]).to eq(procedure.organisation) }
|
||||
it { expect(subject[:direction]).to eq(procedure.direction) }
|
||||
it { expect(subject[:archived_at]).to eq(procedure.archived_at) }
|
||||
it { expect(subject[:archived_at]).to eq(procedure.closed_at) }
|
||||
it { expect(subject[:total_dossier]).to eq(procedure.total_dossier) }
|
||||
it { is_expected.to have_key(:types_de_champ) }
|
||||
it { expect(subject[:types_de_champ]).to be_an(Array) }
|
||||
|
|
|
@ -99,7 +99,7 @@ describe Instructeurs::ProceduresController, type: :controller do
|
|||
|
||||
context "with procedures assigned" do
|
||||
let(:procedure1) { create(:procedure, :published) }
|
||||
let(:procedure2) { create(:procedure, :archived) }
|
||||
let(:procedure2) { create(:procedure, :closed) }
|
||||
let(:procedure3) { create(:procedure) }
|
||||
|
||||
before do
|
||||
|
|
|
@ -423,8 +423,8 @@ describe Users::DossiersController, type: :controller do
|
|||
expect(dossier.reload.state).to eq(Dossier.states.fetch(:en_construction))
|
||||
end
|
||||
|
||||
context "on an archived procedure" do
|
||||
before { dossier.procedure.archive }
|
||||
context "on an closed procedure" do
|
||||
before { dossier.procedure.close! }
|
||||
|
||||
it "it does not change state" do
|
||||
subject
|
||||
|
@ -873,8 +873,8 @@ describe Users::DossiersController, type: :controller do
|
|||
it { is_expected.to redirect_to identite_dossier_path(id: Dossier.last) }
|
||||
end
|
||||
|
||||
context 'when procedure is archived' do
|
||||
let(:procedure) { create(:procedure, :archived) }
|
||||
context 'when procedure is closed' do
|
||||
let(:procedure) { create(:procedure, :closed) }
|
||||
|
||||
it { is_expected.to redirect_to dossiers_path }
|
||||
end
|
||||
|
|
|
@ -160,21 +160,11 @@ FactoryBot.define do
|
|||
end
|
||||
end
|
||||
|
||||
trait :archived do
|
||||
trait :closed do
|
||||
after(:build) do |procedure, _evaluator|
|
||||
procedure.path = generate(:published_path)
|
||||
procedure.publish!
|
||||
procedure.archive!
|
||||
end
|
||||
end
|
||||
|
||||
trait :archived_automatically do
|
||||
# For now the behavior is the same than :archived
|
||||
# (it may be different in the future though)
|
||||
after(:build) do |procedure, _evaluator|
|
||||
procedure.path = generate(:published_path)
|
||||
procedure.publish!
|
||||
procedure.archive!
|
||||
procedure.close!
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -49,8 +49,8 @@ RSpec.describe DossierHelper, type: :helper do
|
|||
context "when dossier state is brouillon" do
|
||||
it { is_expected.to be false }
|
||||
|
||||
context "when dossier state is brouillon and procedure is archivee" do
|
||||
before { dossier.procedure.archive }
|
||||
context "when dossier state is brouillon and procedure is close" do
|
||||
before { dossier.procedure.close }
|
||||
|
||||
it { is_expected.to be true }
|
||||
end
|
||||
|
@ -59,8 +59,8 @@ RSpec.describe DossierHelper, type: :helper do
|
|||
shared_examples_for "returns false" do
|
||||
it { is_expected.to be false }
|
||||
|
||||
context "and procedure is archivee" do
|
||||
before { dossier.procedure.archive }
|
||||
context "and procedure is close" do
|
||||
before { dossier.procedure.close }
|
||||
|
||||
it { is_expected.to be false }
|
||||
end
|
||||
|
|
|
@ -14,7 +14,7 @@ RSpec.describe AutoArchiveProcedureJob, type: :job do
|
|||
procedure.reload
|
||||
end
|
||||
|
||||
it { expect(procedure.archivee?).to eq false }
|
||||
it { expect(procedure.close?).to eq false }
|
||||
end
|
||||
|
||||
context "when procedures have auto_archive_on set on yesterday or today" do
|
||||
|
@ -53,8 +53,8 @@ RSpec.describe AutoArchiveProcedureJob, type: :job do
|
|||
}
|
||||
|
||||
it {
|
||||
expect(procedure_hier.archivee?).to eq true
|
||||
expect(procedure_aujourdhui.archivee?).to eq true
|
||||
expect(procedure_hier.close?).to eq true
|
||||
expect(procedure_aujourdhui.close?).to eq true
|
||||
}
|
||||
end
|
||||
|
||||
|
@ -63,6 +63,6 @@ RSpec.describe AutoArchiveProcedureJob, type: :job do
|
|||
subject
|
||||
end
|
||||
|
||||
it { expect(procedure_demain.archivee?).to eq false }
|
||||
it { expect(procedure_demain.close?).to eq false }
|
||||
end
|
||||
end
|
||||
|
|
|
@ -40,8 +40,8 @@ RSpec.describe FindDubiousProceduresJob, type: :job do
|
|||
it { expect(AdministrationMailer).to have_received(:dubious_procedures).with([]) }
|
||||
end
|
||||
|
||||
context 'and a archived procedure' do
|
||||
let(:procedure) { create(:procedure, :archived) }
|
||||
context 'and a closed procedure' do
|
||||
let(:procedure) { create(:procedure, :closed) }
|
||||
|
||||
it { expect(AdministrationMailer).to have_received(:dubious_procedures).with([]) }
|
||||
end
|
||||
|
|
|
@ -702,8 +702,8 @@ describe Dossier do
|
|||
let(:state) { Dossier.states.fetch(:brouillon) }
|
||||
it { is_expected.to be true }
|
||||
|
||||
context "procedure is archived" do
|
||||
before { procedure.archive }
|
||||
context "procedure is closed" do
|
||||
before { procedure.close! }
|
||||
it { is_expected.to be false }
|
||||
end
|
||||
end
|
||||
|
|
|
@ -356,17 +356,17 @@ describe Procedure do
|
|||
let(:procedure) { create(:procedure) }
|
||||
subject { Procedure.active(procedure.id) }
|
||||
|
||||
context 'when procedure is in draft status and not archived' do
|
||||
context 'when procedure is in draft status and not closed' do
|
||||
it { expect { subject }.to raise_error(ActiveRecord::RecordNotFound) }
|
||||
end
|
||||
|
||||
context 'when procedure is published and not archived' do
|
||||
context 'when procedure is published and not closed' do
|
||||
let(:procedure) { create(:procedure, :published) }
|
||||
it { is_expected.to be_truthy }
|
||||
end
|
||||
|
||||
context 'when procedure is published and archived' do
|
||||
let(:procedure) { create(:procedure, :archived) }
|
||||
context 'when procedure is published and closed' do
|
||||
let(:procedure) { create(:procedure, :closed) }
|
||||
it { expect { subject }.to raise_error(ActiveRecord::RecordNotFound) }
|
||||
end
|
||||
end
|
||||
|
@ -509,10 +509,10 @@ describe Procedure do
|
|||
end
|
||||
|
||||
describe 'procedure status is reset' do
|
||||
let(:procedure) { create(:procedure, :archived, received_mail: received_mail, service: service) }
|
||||
let(:procedure) { create(:procedure, :closed, received_mail: received_mail, service: service) }
|
||||
|
||||
it 'Not published nor archived' do
|
||||
expect(subject.archived_at).to be_nil
|
||||
it 'Not published nor closed' do
|
||||
expect(subject.closed_at).to be_nil
|
||||
expect(subject.published_at).to be_nil
|
||||
expect(subject.aasm_state).to eq "brouillon"
|
||||
expect(subject.path).not_to be_nil
|
||||
|
@ -555,7 +555,7 @@ describe Procedure do
|
|||
end
|
||||
after { Timecop.return }
|
||||
|
||||
it { expect(procedure.archived_at).to eq(nil) }
|
||||
it { expect(procedure.closed_at).to eq(nil) }
|
||||
it { expect(procedure.published_at).to eq(now) }
|
||||
it { expect(Procedure.find_by(path: "example-path")).to eq(procedure) }
|
||||
it { expect(Procedure.find_by(path: "example-path").administrateurs).to eq(procedure.administrateurs) }
|
||||
|
@ -564,41 +564,41 @@ describe Procedure do
|
|||
describe "#brouillon?" do
|
||||
let(:procedure_brouillon) { Procedure.new() }
|
||||
let(:procedure_publiee) { Procedure.new(aasm_state: :publiee, published_at: Time.zone.now) }
|
||||
let(:procedure_archivee) { Procedure.new(aasm_state: :archivee, published_at: Time.zone.now, archived_at: Time.zone.now) }
|
||||
let(:procedure_close) { Procedure.new(aasm_state: :close, published_at: Time.zone.now, closed_at: Time.zone.now) }
|
||||
|
||||
it { expect(procedure_brouillon.brouillon?).to be_truthy }
|
||||
it { expect(procedure_publiee.brouillon?).to be_falsey }
|
||||
it { expect(procedure_archivee.brouillon?).to be_falsey }
|
||||
it { expect(procedure_close.brouillon?).to be_falsey }
|
||||
end
|
||||
|
||||
describe "#publiee?" do
|
||||
let(:procedure_brouillon) { Procedure.new() }
|
||||
let(:procedure_publiee) { Procedure.new(aasm_state: :publiee, published_at: Time.zone.now) }
|
||||
let(:procedure_archivee) { Procedure.new(aasm_state: :archivee, published_at: Time.zone.now, archived_at: Time.zone.now) }
|
||||
let(:procedure_close) { Procedure.new(aasm_state: :close, published_at: Time.zone.now, closed_at: Time.zone.now) }
|
||||
|
||||
it { expect(procedure_brouillon.publiee?).to be_falsey }
|
||||
it { expect(procedure_publiee.publiee?).to be_truthy }
|
||||
it { expect(procedure_archivee.publiee?).to be_falsey }
|
||||
it { expect(procedure_close.publiee?).to be_falsey }
|
||||
end
|
||||
|
||||
describe "#archivee?" do
|
||||
describe "#close?" do
|
||||
let(:procedure_brouillon) { Procedure.new() }
|
||||
let(:procedure_publiee) { Procedure.new(aasm_state: :publiee, published_at: Time.zone.now) }
|
||||
let(:procedure_archivee) { Procedure.new(aasm_state: :archivee, published_at: Time.zone.now, archived_at: Time.zone.now) }
|
||||
let(:procedure_close) { Procedure.new(aasm_state: :close, published_at: Time.zone.now, closed_at: Time.zone.now) }
|
||||
|
||||
it { expect(procedure_brouillon.archivee?).to be_falsey }
|
||||
it { expect(procedure_publiee.archivee?).to be_falsey }
|
||||
it { expect(procedure_archivee.archivee?).to be_truthy }
|
||||
it { expect(procedure_brouillon.close?).to be_falsey }
|
||||
it { expect(procedure_publiee.close?).to be_falsey }
|
||||
it { expect(procedure_close.close?).to be_truthy }
|
||||
end
|
||||
|
||||
describe "#publiee_ou_archivee?" do
|
||||
describe "#publiee_ou_close?" do
|
||||
let(:procedure_brouillon) { Procedure.new() }
|
||||
let(:procedure_publiee) { Procedure.new(aasm_state: :publiee, published_at: Time.zone.now) }
|
||||
let(:procedure_archivee) { Procedure.new(aasm_state: :archivee, published_at: Time.zone.now, archived_at: Time.zone.now) }
|
||||
let(:procedure_close) { Procedure.new(aasm_state: :close, published_at: Time.zone.now, closed_at: Time.zone.now) }
|
||||
|
||||
it { expect(procedure_brouillon.publiee_ou_archivee?).to be_falsey }
|
||||
it { expect(procedure_publiee.publiee_ou_archivee?).to be_truthy }
|
||||
it { expect(procedure_archivee.publiee_ou_archivee?).to be_truthy }
|
||||
it { expect(procedure_brouillon.publiee_ou_close?).to be_falsey }
|
||||
it { expect(procedure_publiee.publiee_ou_close?).to be_truthy }
|
||||
it { expect(procedure_close.publiee_ou_close?).to be_truthy }
|
||||
end
|
||||
|
||||
describe 'archive' do
|
||||
|
@ -606,13 +606,13 @@ describe Procedure do
|
|||
let(:now) { Time.zone.now.beginning_of_minute }
|
||||
before do
|
||||
Timecop.freeze(now)
|
||||
procedure.archive!
|
||||
procedure.close!
|
||||
procedure.reload
|
||||
end
|
||||
after { Timecop.return }
|
||||
|
||||
it { expect(procedure.archivee?).to be_truthy }
|
||||
it { expect(procedure.archived_at).to eq(now) }
|
||||
it { expect(procedure.close?).to be_truthy }
|
||||
it { expect(procedure.closed_at).to eq(now) }
|
||||
end
|
||||
|
||||
describe 'path_customized?' do
|
||||
|
|
|
@ -83,8 +83,8 @@ describe AdministrateurUsageStatisticsService do
|
|||
end
|
||||
end
|
||||
|
||||
context 'with a procedure archivee' do
|
||||
let(:procedure) { create(:procedure, aasm_state: 'archivee') }
|
||||
context 'with a procedure close' do
|
||||
let(:procedure) { create(:procedure, aasm_state: 'close') }
|
||||
let!(:dossiers) do
|
||||
(1..7).flat_map do
|
||||
[
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'admin/procedures/show.html.haml', type: :view do
|
||||
let(:archived_at) { nil }
|
||||
let(:procedure) { create(:procedure, :with_service, archived_at: archived_at) }
|
||||
let(:closed_at) { nil }
|
||||
let(:procedure) { create(:procedure, :with_service, closed_at: closed_at) }
|
||||
|
||||
before do
|
||||
assign(:procedure, procedure)
|
||||
|
@ -58,10 +58,10 @@ describe 'admin/procedures/show.html.haml', type: :view do
|
|||
end
|
||||
end
|
||||
|
||||
describe 'procedure is archived' do
|
||||
describe 'procedure is closed' do
|
||||
before do
|
||||
procedure.publish!
|
||||
procedure.archive!
|
||||
procedure.close!
|
||||
procedure.reload
|
||||
render
|
||||
end
|
||||
|
@ -73,7 +73,7 @@ describe 'admin/procedures/show.html.haml', type: :view do
|
|||
end
|
||||
|
||||
describe 'procedure link is present' do
|
||||
it { expect(rendered).to have_content('Cette démarche est archivée et n’est donc plus accessible par le public.') }
|
||||
it { expect(rendered).to have_content('Cette démarche est close et n’est donc plus accessible par le public.') }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -13,12 +13,12 @@ describe 'users/dossiers/dossier_actions.html.haml', type: :view do
|
|||
end
|
||||
|
||||
context 'when the procedure is closed' do
|
||||
let(:procedure) { create(:procedure, :archived) }
|
||||
let(:procedure) { create(:procedure, :closed) }
|
||||
it { is_expected.not_to have_link('Commencer un autre dossier') }
|
||||
end
|
||||
|
||||
context 'when there are no actions to display' do
|
||||
let(:procedure) { create(:procedure, :archived) }
|
||||
let(:procedure) { create(:procedure, :closed) }
|
||||
let(:dossier) { create(:dossier, :accepte, procedure: procedure) }
|
||||
|
||||
it 'doesn’t render the menu at all' do
|
||||
|
|
Loading…
Reference in a new issue