diff --git a/app/controllers/concerns/create_avis_concern.rb b/app/controllers/concerns/create_avis_concern.rb index 9854ec405..ea3e9eb3c 100644 --- a/app/controllers/concerns/create_avis_concern.rb +++ b/app/controllers/concerns/create_avis_concern.rb @@ -34,6 +34,7 @@ module CreateAvisConcern end end ) + dossier.avis.reload # unload non-persisted avis from dossier persisted, failed = create_results.partition(&:persisted?) diff --git a/app/models/champ.rb b/app/models/champ.rb index 8cb1d8804..780f3c7b6 100644 --- a/app/models/champ.rb +++ b/app/models/champ.rb @@ -45,6 +45,7 @@ class Champ < ApplicationRecord :repetition?, :dossier_link?, :titre_identite?, + :header_section?, to: :type_de_champ scope :updated_since?, -> (date) { where('champs.updated_at > ?', date) } @@ -86,6 +87,10 @@ class Champ < ApplicationRecord end end + def sections + siblings.filter(&:header_section?) + end + def mandatory_and_blank? mandatory? && blank? end diff --git a/app/models/champs/header_section_champ.rb b/app/models/champs/header_section_champ.rb index 59fd78da0..3ea8874a6 100644 --- a/app/models/champs/header_section_champ.rb +++ b/app/models/champs/header_section_champ.rb @@ -22,9 +22,19 @@ class Champs::HeaderSectionChamp < Champ # The user cannot enter any information here so it doesn’t make much sense to search end + def libelle_with_section_index + if sections.none?(&:libelle_with_section_index?) + "#{section_index}. #{libelle}" + else + libelle + end + end + + def libelle_with_section_index? + libelle =~ /^\d/ + end + def section_index - siblings - .filter { |c| c.type_champ == TypeDeChamp.type_champs.fetch(:header_section) } - .index(self) + 1 + sections.index(self) + 1 end end diff --git a/app/models/type_de_champ.rb b/app/models/type_de_champ.rb index 913975f58..88fa0585c 100644 --- a/app/models/type_de_champ.rb +++ b/app/models/type_de_champ.rb @@ -174,6 +174,10 @@ class TypeDeChamp < ApplicationRecord ]) end + def header_section? + type_champ == TypeDeChamp.type_champs.fetch(:header_section) + end + def linked_drop_down_list? type_champ == TypeDeChamp.type_champs.fetch(:linked_drop_down_list) end diff --git a/app/views/admin/instructeurs/index.html.haml b/app/views/admin/instructeurs/index.html.haml index 8de1e612b..abb6ddbc1 100644 --- a/app/views/admin/instructeurs/index.html.haml +++ b/app/views/admin/instructeurs/index.html.haml @@ -18,7 +18,7 @@ .col-xs-6 %h3 Ajouter un instructeur #procedure_new.section.section-label - = form_with url: { controller: 'admin/instructeurs', action: :create }, local: true do + = form_with url: { controller: 'admin/instructeurs', action: :create } do .row .col-xs-5 = render partial: 'admin/instructeurs/informations' diff --git a/app/views/new_administrateur/procedures/jeton.html.haml b/app/views/new_administrateur/procedures/jeton.html.haml index 2e4341d38..503f601e6 100644 --- a/app/views/new_administrateur/procedures/jeton.html.haml +++ b/app/views/new_administrateur/procedures/jeton.html.haml @@ -9,7 +9,7 @@ .container %h1 - = form_with model: @procedure, url: url_for({ controller: 'new_administrateur/procedures', action: :update_jeton }), local: true, html: { class: 'form' } do |f| + = form_with model: @procedure, url: url_for({ controller: 'new_administrateur/procedures', action: :update_jeton }), html: { class: 'form' } do |f| %p.explication Démarches Simplifiées utilise = link_to 'API Entreprise', "https://entreprise.api.gouv.fr/" diff --git a/app/views/shared/dossiers/editable_champs/_header_section.html.haml b/app/views/shared/dossiers/editable_champs/_header_section.html.haml index 5e40893c5..030efcd2b 100644 --- a/app/views/shared/dossiers/editable_champs/_header_section.html.haml +++ b/app/views/shared/dossiers/editable_champs/_header_section.html.haml @@ -1,5 +1,2 @@ %h2.header-section - - libelle_starts_with_number = (champ.libelle =~ /^\d/) - - if !libelle_starts_with_number - = "#{champ.section_index}." - = champ.libelle + = champ.libelle_with_section_index diff --git a/config/application.rb b/config/application.rb index 20e021ce7..4598e3212 100644 --- a/config/application.rb +++ b/config/application.rb @@ -11,7 +11,7 @@ Dotenv::Railtie.load module TPS class Application < Rails::Application # Initialize configuration defaults for originally generated Rails version. - config.load_defaults 6.0 + config.load_defaults 6.1 # Configuration for the application, engines, and railties goes here. # @@ -65,6 +65,12 @@ module TPS # disable the check performed by Rails. config.action_dispatch.ip_spoofing_check = false + # Set the queue name for the mail delivery jobs to 'mailers' + config.action_mailer.deliver_later_queue_name = :mailers + + # Set the queue name for the analysis jobs to 'active_storage_analysis' + config.active_storage.queues.analysis = :active_storage_analysis + config.to_prepare do # Make main application helpers available in administrate Administrate::ApplicationController.helper(TPS::Application.helpers) diff --git a/config/env.example.optional b/config/env.example.optional index df8dcca74..8420512d0 100644 --- a/config/env.example.optional +++ b/config/env.example.optional @@ -35,6 +35,9 @@ DS_ENV="staging" # Personnalisation d'instance - URL du site web FAQ # FAQ_URL="https://faq.demarches-simplifiees.fr" +# Personnalisation d'instance - URL de la déclaration d'accessibilité +# ACCESSIBILITE_URL="" + # Personnalisation d'instance - Page externe "Disponibilité" (status page) # STATUS_PAGE_URL="" diff --git a/config/initializers/new_framework_defaults_6_1.rb b/config/initializers/new_framework_defaults_6_1.rb deleted file mode 100644 index 9526b835a..000000000 --- a/config/initializers/new_framework_defaults_6_1.rb +++ /dev/null @@ -1,67 +0,0 @@ -# Be sure to restart your server when you modify this file. -# -# This file contains migration options to ease your Rails 6.1 upgrade. -# -# Once upgraded flip defaults one by one to migrate to the new default. -# -# Read the Guide for Upgrading Ruby on Rails for more info on each option. - -# Support for inversing belongs_to -> has_many Active Record associations. -# Rails.application.config.active_record.has_many_inversing = true - -# Track Active Storage variants in the database. -# Rails.application.config.active_storage.track_variants = true - -# Apply random variation to the delay when retrying failed jobs. -# Rails.application.config.active_job.retry_jitter = 0.15 - -# Stop executing `after_enqueue`/`after_perform` callbacks if -# `before_enqueue`/`before_perform` respectively halts with `throw :abort`. -# Rails.application.config.active_job.skip_after_callbacks_if_terminated = true - -# Specify cookies SameSite protection level: either :none, :lax, or :strict. -# -# This change is not backwards compatible with earlier Rails versions. -# It's best enabled when your entire app is migrated and stable on 6.1. -# Rails.application.config.action_dispatch.cookies_same_site_protection = :lax - -# Generate CSRF tokens that are encoded in URL-safe Base64. -# -# This change is not backwards compatible with earlier Rails versions. -# It's best enabled when your entire app is migrated and stable on 6.1. -# Rails.application.config.action_controller.urlsafe_csrf_tokens = true - -# Specify whether `ActiveSupport::TimeZone.utc_to_local` returns a time with an -# UTC offset or a UTC time. -# ActiveSupport.utc_to_local_returns_utc_offset_times = true - -# Change the default HTTP status code to `308` when redirecting non-GET/HEAD -# requests to HTTPS in `ActionDispatch::SSL` middleware. -# Rails.application.config.action_dispatch.ssl_default_redirect_status = 308 - -# Use new connection handling API. For most applications this won't have any -# effect. For applications using multiple databases, this new API provides -# support for granular connection swapping. -# Rails.application.config.active_record.legacy_connection_handling = false - -# Make `form_with` generate non-remote forms by default. -# Rails.application.config.action_view.form_with_generates_remote_forms = false - -# Set the default queue name for the analysis job to the queue adapter default. -# Rails.application.config.active_storage.queues.analysis = nil - -# Set the default queue name for the purge job to the queue adapter default. -# Rails.application.config.active_storage.queues.purge = nil - -# Set the default queue name for the incineration job to the queue adapter default. -# Rails.application.config.action_mailbox.queues.incineration = nil - -# Set the default queue name for the routing job to the queue adapter default. -# Rails.application.config.action_mailbox.queues.routing = nil - -# Set the default queue name for the mail deliver job to the queue adapter default. -# Rails.application.config.action_mailer.deliver_later_queue_name = nil - -# Generate a `Link` header that gives a hint to modern browsers about -# preloading assets when using `javascript_include_tag` and `stylesheet_link_tag`. -# Rails.application.config.action_view.preload_links_header = true diff --git a/spec/lib/active_storage/downloadable_file_spec.rb b/spec/lib/active_storage/downloadable_file_spec.rb index 6fc938311..200c519f7 100644 --- a/spec/lib/active_storage/downloadable_file_spec.rb +++ b/spec/lib/active_storage/downloadable_file_spec.rb @@ -27,7 +27,7 @@ describe ActiveStorage::DownloadableFile do context 'when there is a repetition bloc' do before do - dossier.champs << build(:champ_repetition_with_piece_jointe, dossier: dossier) + dossier.champs << create(:champ_repetition_with_piece_jointe, dossier: dossier) end it 'should have 4 piece_justificatives' do diff --git a/spec/services/dossier_search_service_spec.rb b/spec/services/dossier_search_service_spec.rb index 52f855c27..c004f1d5a 100644 --- a/spec/services/dossier_search_service_spec.rb +++ b/spec/services/dossier_search_service_spec.rb @@ -23,15 +23,15 @@ describe DossierSearchService do 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: Dossier.states.fetch(:en_construction), procedure: procedure_1, user: create(:user, email: 'contact@test.com'), etablissement: etablissement_1) } + let!(:dossier_1) { create(:dossier, :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: Dossier.states.fetch(:en_construction), procedure: procedure_1, user: create(:user, email: 'plop@gmail.com'), etablissement: etablissement_2) } + let!(:dossier_2) { create(:dossier, :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: Dossier.states.fetch(:en_construction), procedure: procedure_2, user: create(:user, email: 'peace@clap.fr'), etablissement: etablissement_3) } + let!(:dossier_3) { create(:dossier, :en_construction, procedure: procedure_2, user: create(:user, email: 'peace@clap.fr'), etablissement: etablissement_3) } - let!(:dossier_archived) { create(:dossier, state: Dossier.states.fetch(:en_construction), procedure: procedure_1, archived: true, user: create(:user, email: 'archived@clap.fr')) } + let!(:dossier_archived) { create(:dossier, :en_construction, procedure: procedure_1, archived: true, user: create(:user, email: 'archived@clap.fr')) } describe 'search is empty' do let(:terms) { '' }