diff --git a/app/assets/javascripts/old_design/procedure.js b/app/assets/javascripts/old_design/procedure.js index c2bcffb54..a1c0c53c6 100644 --- a/app/assets/javascripts/old_design/procedure.js +++ b/app/assets/javascripts/old_design/procedure.js @@ -2,7 +2,6 @@ $(document).on('turbolinks:load', button_edit_procedure_init); function button_edit_procedure_init(){ buttons_api_carto(); - button_cerfa(); button_individual(); } @@ -16,16 +15,6 @@ function buttons_api_carto () { $("#modules-api-carto").show(); } -function button_cerfa () { - - $("#procedure_cerfa_flag").on('change', function() { - $("#procedure-lien-demarche").toggle() - }); - - if ($('#procedure_cerfa_flag').is(':checked')) - $("#procedure-lien-demarche").show(); -} - function button_individual () { $("#procedure_for_individual").on('change', function() { diff --git a/app/controllers/admin/procedures_controller.rb b/app/controllers/admin/procedures_controller.rb index 60b0f034d..ae08d5001 100644 --- a/app/controllers/admin/procedures_controller.rb +++ b/app/controllers/admin/procedures_controller.rb @@ -237,7 +237,7 @@ class Admin::ProceduresController < AdminController if @procedure&.locked? params.require(:procedure).permit(*editable_params) else - params.require(:procedure).permit(*editable_params, :duree_conservation_dossiers_dans_ds, :duree_conservation_dossiers_hors_ds, :lien_demarche, :cerfa_flag, :for_individual, :individual_with_siret, :ask_birthday, module_api_carto_attributes: [:id, :use_api_carto, :quartiers_prioritaires, :cadastre]).merge(administrateur_id: current_administrateur.id) + params.require(:procedure).permit(*editable_params, :duree_conservation_dossiers_dans_ds, :duree_conservation_dossiers_hors_ds, :lien_demarche, :for_individual, :individual_with_siret, :ask_birthday, module_api_carto_attributes: [:id, :use_api_carto, :quartiers_prioritaires, :cadastre]).merge(administrateur_id: current_administrateur.id) end end diff --git a/app/controllers/users/description_controller.rb b/app/controllers/users/description_controller.rb index 9080ae890..4116b24c5 100644 --- a/app/controllers/users/description_controller.rb +++ b/app/controllers/users/description_controller.rb @@ -31,11 +31,6 @@ class Users::DescriptionController < UsersController ChampsService.save_champs(dossier.champs, params) if params[:champs] - if procedure.cerfa_flag? && params[:cerfa_pdf] - cerfa = Cerfa.new(content: params[:cerfa_pdf], dossier: dossier, user: current_user) - return redirect_to_description_with_errors(dossier, cerfa.errors.full_messages) if !cerfa.save - end - errors_upload = PiecesJustificativesService.upload!(dossier, current_user, params) + ChampsService.check_piece_justificative_files(dossier.champs) return redirect_to_description_with_errors(dossier, errors_upload) if errors_upload.any? @@ -68,15 +63,6 @@ class Users::DescriptionController < UsersController @dossier ||= Dossier.find(params[:dossier_id]) if invite @dossier ||= current_user_dossier - if @dossier.procedure.cerfa_flag? - if params[:cerfa_pdf].present? - cerfa = Cerfa.new(content: params[:cerfa_pdf], dossier: @dossier, user: current_user) - if !cerfa.save - flash.alert = cerfa.errors.full_messages - end - end - end - if (errors_upload = PiecesJustificativesService.upload!(@dossier, current_user, params)).present? if flash.alert.nil? flash.alert = errors_upload diff --git a/app/facades/dossier_facades.rb b/app/facades/dossier_facades.rb index 9539cc724..9c291942f 100644 --- a/app/facades/dossier_facades.rb +++ b/app/facades/dossier_facades.rb @@ -37,10 +37,6 @@ class DossierFacades @dossier.procedure end - def cerfas_ordered - @dossier.cerfa.order('created_at DESC') - end - def invites @dossier.invites end diff --git a/app/models/cerfa.rb b/app/models/cerfa.rb deleted file mode 100644 index 2a8a27270..000000000 --- a/app/models/cerfa.rb +++ /dev/null @@ -1,21 +0,0 @@ -class Cerfa < ApplicationRecord - belongs_to :dossier, touch: true - belongs_to :user - - mount_uploader :content, CerfaUploader - validates :content, :file_size => { :maximum => 20.megabytes } - - def empty? - content.blank? - end - - def content_url - if content.url.present? - if Flipflop.remote_storage? - (RemoteDownloader.new content.filename).url - else - (LocalDownloader.new content.path, 'CERFA').url - end - end - end -end diff --git a/app/models/champs/linked_drop_down_list_champ.rb b/app/models/champs/linked_drop_down_list_champ.rb index ef02e78f4..0b1b68875 100644 --- a/app/models/champs/linked_drop_down_list_champ.rb +++ b/app/models/champs/linked_drop_down_list_champ.rb @@ -28,8 +28,24 @@ class Champs::LinkedDropDownListChamp < Champ :primary_value end + def for_display + string_value + end + + def mandatory_and_blank? + mandatory? && (primary_value.blank? || secondary_value.blank?) + end + private + def string_value + [primary_value, secondary_value].compact.join(' / ') + end + + def value_for_export + "#{primary_value || ''};#{secondary_value || ''}" + end + def pack_value self.value = JSON.generate([ primary_value, secondary_value ]) end diff --git a/app/models/dossier.rb b/app/models/dossier.rb index c02facd83..a6452b395 100644 --- a/app/models/dossier.rb +++ b/app/models/dossier.rb @@ -16,7 +16,6 @@ class Dossier < ApplicationRecord has_one :etablissement, dependent: :destroy has_one :individual, dependent: :destroy has_one :attestation - has_many :cerfa, dependent: :destroy has_many :pieces_justificatives, dependent: :destroy has_many :champs, -> { public_only }, dependent: :destroy @@ -127,10 +126,6 @@ class Dossier < ApplicationRecord INSTRUCTION_COMMENCEE.include?(state) end - def cerfa_available? - procedure.cerfa_flag? && cerfa.size != 0 - end - def export_headers serialized_dossier = DossierTableExportSerializer.new(self) headers = serialized_dossier.attributes.keys diff --git a/app/models/procedure.rb b/app/models/procedure.rb index 8a0e216a0..f7d7b8a6f 100644 --- a/app/models/procedure.rb +++ b/app/models/procedure.rb @@ -222,6 +222,10 @@ class Procedure < ApplicationRecord procedure.cloned_from_library = from_library procedure.parent_procedure = self + if from_library + procedure.service = nil + end + procedure end diff --git a/app/models/user.rb b/app/models/user.rb index 7ecbac5ff..7770f5a22 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -16,7 +16,6 @@ class User < ApplicationRecord has_many :invites, dependent: :destroy has_many :dossiers_invites, through: :invites, source: :dossier has_many :piece_justificative, dependent: :destroy - has_many :cerfa, dependent: :destroy has_one :france_connect_information, dependent: :destroy delegate :given_name, :family_name, :email_france_connect, :gender, :birthdate, :birthplace, :france_connect_particulier_id, to: :france_connect_information diff --git a/app/serializers/cerfa_serializer.rb b/app/serializers/cerfa_serializer.rb deleted file mode 100644 index 1971db96a..000000000 --- a/app/serializers/cerfa_serializer.rb +++ /dev/null @@ -1,6 +0,0 @@ -class CerfaSerializer < ActiveModel::Serializer - attributes :created_at, - :content_url - - has_one :user -end diff --git a/app/serializers/champs/linked_drop_down_list_champ_serializer.rb b/app/serializers/champs/linked_drop_down_list_champ_serializer.rb new file mode 100644 index 000000000..01d91cb84 --- /dev/null +++ b/app/serializers/champs/linked_drop_down_list_champ_serializer.rb @@ -0,0 +1,5 @@ +class Champs::LinkedDropDownListChampSerializer < ChampSerializer + def value + { primary: object.primary_value, secondary: object.secondary_value } + end +end diff --git a/app/serializers/dossier_serializer.rb b/app/serializers/dossier_serializer.rb index 41204b774..86f9d82db 100644 --- a/app/serializers/dossier_serializer.rb +++ b/app/serializers/dossier_serializer.rb @@ -30,6 +30,10 @@ class DossierSerializer < ActiveModel::Serializer champs end + def cerfa + [] + end + def email object.user&.email end diff --git a/app/uploaders/cerfa_uploader.rb b/app/uploaders/cerfa_uploader.rb deleted file mode 100644 index 38fbc9109..000000000 --- a/app/uploaders/cerfa_uploader.rb +++ /dev/null @@ -1,49 +0,0 @@ -class CerfaUploader < BaseUploader - before :cache, :set_original_filename - - # Choose what kind of storage to use for this uploader: - if Flipflop.remote_storage? - storage :fog - else - storage :file - end - - # Override the directory where uploaded files will be stored. - # This is a sensible default for uploaders that are meant to be mounted: - def store_dir - if !Flipflop.remote_storage? - "./uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}" - end - end - - # Add a white list of extensions which are allowed to be uploaded. - # For images you might use something like this: - def extension_white_list - %w(pdf doc docx xls xlsx ppt pptx odt ods odp jpg jpeg png) - end - - def filename - if original_filename.present? || model.content_secure_token - if Flipflop.remote_storage? - filename = "#{model.class.to_s.underscore}-#{secure_token}.#{file.extension.downcase}" - else - filename = "#{model.class.to_s.underscore}.#{file.extension.downcase}" - end - end - filename - end - - private - - def secure_token - model.content_secure_token ||= generate_secure_token - end - - def generate_secure_token - SecureRandom.uuid - end - - def set_original_filename(file) - model.original_filename ||= file.original_filename if file.respond_to?(:original_filename) - end -end diff --git a/app/views/admin/procedures/_informations.html.haml b/app/views/admin/procedures/_informations.html.haml index e78592f38..239106f53 100644 --- a/app/views/admin/procedures/_informations.html.haml +++ b/app/views/admin/procedures/_informations.html.haml @@ -106,14 +106,6 @@ Cadastre .col-md-6 - - if @procedure.cerfa_flag - %h4 Formulaire de demande ou CERFA - .checkbox - %label - = f.check_box :cerfa_flag - Activer l'envoi de formulaire de demande ou CERFA - %br - = f.text_field :lien_demarche, class: 'form-control', placeholder: 'URL vers le formulaire vierge (facultatif)' .row .col-md-6 diff --git a/app/views/dossiers/_edit_pieces_jointes.html.haml b/app/views/dossiers/_edit_pieces_jointes.html.haml index 497f941a4..df439eb7d 100644 --- a/app/views/dossiers/_edit_pieces_jointes.html.haml +++ b/app/views/dossiers/_edit_pieces_jointes.html.haml @@ -1,6 +1,6 @@ - if !@facade.dossier.read_only? - if user_signed_in? && (current_user.owns_or_invite?(@facade.dossier)) - - if @facade.procedure.cerfa_flag? || @facade.dossier.types_de_piece_justificative.size > 0 + - if @facade.dossier.types_de_piece_justificative.size > 0 .col-lg-4.col-md-4.col-sm-4.col-xs-4.action %a#maj_pj.action{ "data-target" => "#upload-pj-modal", "data-toggle" => "modal", diff --git a/app/views/dossiers/_infos_dossier.html.haml b/app/views/dossiers/_infos_dossier.html.haml index 5da92d8d8..e31391469 100644 --- a/app/views/dossiers/_infos_dossier.html.haml +++ b/app/views/dossiers/_infos_dossier.html.haml @@ -50,11 +50,13 @@ = render partial: "shared/champs/piece_justificative/pj_link", locals: { champ: champ, user_can_upload: true } - elsif champ.type_champ == 'textarea' = simple_format(champ.decorate.value) + - elsif champ.type_champ == 'linked_drop_down_list' + = champ.for_display - else = sanitize(champ.decorate.value) .row - - if @facade.procedure.cerfa_flag? || @facade.dossier.types_de_piece_justificative.count > 0 + - if @facade.dossier.types_de_piece_justificative.count > 0 .col-xs-12 .row.title-row .col-xs-4.split-hr @@ -62,21 +64,6 @@ .col-xs-4.split-hr .col-xs-12#pieces-justificatives.margin-bot-40 - .row - - if @facade.procedure.cerfa_flag? - .col-xs-12#piece_justificative_0 - .row.piece-row - .col-xs-6.depositaire-label= 'Formulaire' - .col-xs-1.comments-off= "-" - .col-xs-5.despositaire-info - - if @facade.dossier.cerfa_available? - %a{ href: "#{@facade.dossier.cerfa.last.content_url}", target: '_blank' } Consulter - %span{ style: 'margin-left: 12px;' } - \- - = link_to "", class: "historique", "data-toggle" => "modal", "data-target" => "#pj-modal", :type => "button", "data-modal_title" => 'formulaires', "data-modal_index" => 'cerfa' do - %span.fa.fa-clock-o - - else - Pièce non fournie .row .col-xs-12 - @facade.types_de_pieces_justificatives.each do |type_de_piece_justificative| @@ -100,7 +87,7 @@ - if !@facade.dossier.read_only? - if user_signed_in? && (current_user.owns_or_invite?(@facade.dossier)) - - if @facade.procedure.cerfa_flag? || @facade.dossier.types_de_piece_justificative.size > 0 + - if @facade.dossier.types_de_piece_justificative.size > 0 .row .col-xs-4 %a#maj_pj.action{ "data-target" => "#upload-pj-modal", "data-toggle" => "modal", :type => "button" } @@ -130,16 +117,6 @@ %th Lien %thead.tr-content#cerfa - - if @facade.procedure.cerfa_flag? - - if @facade.dossier.cerfa_available? - - @facade.cerfas_ordered.each do |cerfa| - %tr - %td.col-md-6.col-sm-6.col-xs-6.col-lg-4 - = cerfa.user.email - %td.col-md-6.col-sm-6.col-xs-6.col-lg-4 - = cerfa.created_at - %td.col-md-6.col-sm-6.col-xs-6.col-lg-4 - = link_to 'Récupérer', cerfa.content_url, { target: :blank } - @facade.dossier.types_de_piece_justificative.each do |type_de_piece_justificative| %tbody.tr-content{ id: "type_de_pj_#{type_de_piece_justificative.id}" } - @facade.dossier.retrieve_all_piece_justificative_by_type(type_de_piece_justificative.id).each do |piece_justificative| diff --git a/app/views/dossiers/_infos_pieces_jointes.html.haml b/app/views/dossiers/_infos_pieces_jointes.html.haml index ccef97395..1fd5bdeaa 100644 --- a/app/views/dossiers/_infos_pieces_jointes.html.haml +++ b/app/views/dossiers/_infos_pieces_jointes.html.haml @@ -1,24 +1,4 @@ #pieces-justificatives - .row - - if @facade.procedure.cerfa_flag? - .col-xs-12#piece_justificative_0 - .row.piece-row - .col-xs-6.piece-label= 'Formulaire' - .col-md-1.col-lg-1.col-sm-1.col-xs-1.comments-off= "-" - .col-xs-5 - - if @facade.dossier.cerfa_available? - %a{ href: "#{@facade.dossier.cerfa.last.content_url}", target: '_blank' } Consulter - %span{ style: 'margin-left: 12px;' } - \- - %a.btn.fa.fa-timer{ style: 'color: black; padding-top: 0;', - "data-target" => "#pj-modal", - "data-toggle" => "modal", - :type => "button", - "data-modal_title" => 'formulaires', - "data-modal_index" => 'cerfa' } - - else - = 'Pièce non fournie' - .row .col-xs-12 - @facade.dossier.types_de_piece_justificative.order('order_place ASC').each do |type_de_piece_justificative| diff --git a/app/views/dossiers/_pieces_justificatives.html.haml b/app/views/dossiers/_pieces_justificatives.html.haml index e5ddebb0d..4d945b685 100644 --- a/app/views/dossiers/_pieces_justificatives.html.haml +++ b/app/views/dossiers/_pieces_justificatives.html.haml @@ -1,23 +1,5 @@ #pieces-justificatives %table.table - - if @facade.procedure.cerfa_flag? - %tr#piece_justificative_0 - %th.col-lg-6 - Formulaire - %td.col-lg-6.col-md-6.col-sm-6.col-xs-6 - - if @facade.dossier.cerfa_available? - %a{ href: "#{@facade.dossier.cerfa.last.content_url}", target: '_blank' } Consulter - %span{ style: 'margin-left: 12px;' } - \- - %a.btn.fa.fa-timer{ style: 'color: black; padding-top: 0;', - "data-target" => "#pj-modal", - "data-toggle" => "modal", - :type => "button", - "data-modal_title" => 'formulaires', - "data-modal_index" => 'cerfa' } - - else - Pièce non fournie - - @facade.dossier.types_de_piece_justificative.order('order_place ASC').each do |type_de_piece_justificative| %tr{ id: "piece_justificative_#{type_de_piece_justificative.id}" } %th.col-lg-6 diff --git a/app/views/new_gestionnaire/dossiers/_champs.html.haml b/app/views/new_gestionnaire/dossiers/_champs.html.haml index 2cdda4cb3..57d6d0e35 100644 --- a/app/views/new_gestionnaire/dossiers/_champs.html.haml +++ b/app/views/new_gestionnaire/dossiers/_champs.html.haml @@ -15,6 +15,10 @@ - c.value.split(", ").each do |item| %li = item + - when "linked_drop_down_list" + %th.libelle + = "#{c.libelle} :" + %td= c.for_display - when "dossier_link" %th.libelle = "#{c.libelle} :" diff --git a/app/views/new_gestionnaire/dossiers/_pieces_jointes.html.haml b/app/views/new_gestionnaire/dossiers/_pieces_jointes.html.haml index 7618de5bc..15a37ab20 100644 --- a/app/views/new_gestionnaire/dossiers/_pieces_jointes.html.haml +++ b/app/views/new_gestionnaire/dossiers/_pieces_jointes.html.haml @@ -1,16 +1,5 @@ %table.table.vertical.pj.dossier-champs %tbody - - if dossier.procedure.cerfa_flag? - %tr - %th Formulaire : - %td - - if @dossier.cerfa_available? - = link_to "Télécharger", @dossier.cerfa.last.content_url, class: "link", target: :blank - - else - Pièce non fournie - %td - - - dossier.procedure.types_de_piece_justificative.each do |type_de_piece_justificative| - pjs = dossier.retrieve_all_piece_justificative_by_type(type_de_piece_justificative.id).to_ary.dup - pj = pjs.shift if pjs.present? diff --git a/app/views/new_gestionnaire/dossiers/print.html.haml b/app/views/new_gestionnaire/dossiers/print.html.haml index 0488c29b7..88017ec0c 100644 --- a/app/views/new_gestionnaire/dossiers/print.html.haml +++ b/app/views/new_gestionnaire/dossiers/print.html.haml @@ -33,19 +33,10 @@ %tr %td= "Parcelle n° #{p.numero} - Feuille #{p.code_arr} #{p.section} #{p.feuille}" -- if @dossier.procedure.cerfa_flag? || @dossier.types_de_piece_justificative.any? +- if @dossier.types_de_piece_justificative.any? %h3 Pièces jointes %table - - if @dossier.procedure.cerfa_flag? - %tr - %th Formulaire : - %td - - if @dossier.cerfa_available? - Pièce fournie - - else - Pièce non fournie - - @dossier.procedure.types_de_piece_justificative.each do |type_de_piece_justificative| %tr %th= "#{type_de_piece_justificative.libelle} :" diff --git a/app/views/new_gestionnaire/shared/_show.html.haml b/app/views/new_gestionnaire/shared/_show.html.haml index aee816d8d..ac26279b8 100644 --- a/app/views/new_gestionnaire/shared/_show.html.haml +++ b/app/views/new_gestionnaire/shared/_show.html.haml @@ -20,7 +20,7 @@ .card = render partial: "new_gestionnaire/dossiers/map", locals: { dossier: dossier } - - if dossier.procedure.cerfa_flag? || dossier.types_de_piece_justificative.any? + - if dossier.types_de_piece_justificative.any? .tab-title Pièces jointes .card = render partial: "new_gestionnaire/dossiers/pieces_jointes", locals: { dossier: dossier, demande_seen_at: demande_seen_at } diff --git a/app/views/users/description/_pieces_justificatives.html.haml b/app/views/users/description/_pieces_justificatives.html.haml index fa2713ede..68b4d4ee9 100644 --- a/app/views/users/description/_pieces_justificatives.html.haml +++ b/app/views/users/description/_pieces_justificatives.html.haml @@ -1,23 +1,4 @@ %table.table - - if dossier.procedure.cerfa_flag - %tr - %th - Formulaire de demande ou CERFA (complété et numérisé) - %td - - if dossier.procedure.lien_demarche.present? - %em - Récupérer le formulaire de demande ou CERFA vierge pour mon dossier : - = link_to "Télécharger", sanitize_url(dossier.procedure.lien_demarche), target: :blank, id: :lien_cerfa - -# %a#lien_cerfa{ href: "#{dossier.procedure.lien_demarche}", target: '_blank' } Télécharger - - %td - - if dossier.cerfa_available? - %span.btn.btn-sm.btn-file.btn-success - Modifier - %input#cerfa_pdf{ type: 'file', name: 'cerfa_pdf', accept: PieceJustificative.accept_format, :max_file_size => 6.megabytes } - - else - %input#cerfa_pdf{ type: 'file', name: 'cerfa_pdf', accept: PieceJustificative.accept_format, :max_file_size => 6.megabytes } - - dossier.types_de_piece_justificative.order('order_place ASC').each do |tpj| %tr %th.piece-libelle diff --git a/app/views/users/description/show.html.haml b/app/views/users/description/show.html.haml index e01f65402..79ecf32ae 100644 --- a/app/views/users/description/show.html.haml +++ b/app/views/users/description/show.html.haml @@ -20,7 +20,7 @@ #liste-champs = render partial: 'users/description/champs', locals: { private: false } - - if @procedure.lien_demarche.present? || @procedure.cerfa_flag || @dossier.types_de_piece_justificative.size > 0 + - if @procedure.lien_demarche.present? || @dossier.types_de_piece_justificative.size > 0 %br %h3 Pièces jointes diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 907cb1841..b0f7cc548 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -102,10 +102,6 @@ fr: attributes: content: size_too_big: "La taille du fichier joint est trop importante. Elle doit être inférieure à 20Mo." - cerfa: - attributes: - content: - size_too_big: "La taille du fichier joint est trop importante. Elle doit être inférieure à 20Mo." user: attributes: reset_password_token: diff --git a/db/migrate/20180627092237_update_searches_to_version_4.rb b/db/migrate/20180627092237_update_searches_to_version_4.rb new file mode 100644 index 000000000..92bc9a8b7 --- /dev/null +++ b/db/migrate/20180627092237_update_searches_to_version_4.rb @@ -0,0 +1,9 @@ +class UpdateSearchesToVersion4 < ActiveRecord::Migration[5.2] + def up + replace_view :searches, version: 4 + end + + def down + replace_view :searches, version: 3 + end +end diff --git a/db/schema.rb b/db/schema.rb index 1a351cd1d..0dc4b2cc9 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2018_06_01_084546) do +ActiveRecord::Schema.define(version: 2018_06_27_092237) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -632,11 +632,10 @@ ActiveRecord::Schema.define(version: 2018_06_01_084546) do create_view "searches", sql_definition: <<-SQL SELECT dossiers.id AS dossier_id, - (((((((((((((((((((((((((((((((((((((((((((((((((((((((COALESCE(users.email, ''::character varying))::text || ' '::text) || (COALESCE(france_connect_informations.given_name, ''::character varying))::text) || ' '::text) || (COALESCE(france_connect_informations.family_name, ''::character varying))::text) || ' '::text) || (COALESCE(cerfas.content, ''::character varying))::text) || ' '::text) || (COALESCE(champs.value, ''::character varying))::text) || ' '::text) || (COALESCE(drop_down_lists.value, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.entreprise_siren, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.entreprise_numero_tva_intracommunautaire, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.entreprise_forme_juridique, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.entreprise_forme_juridique_code, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.entreprise_nom_commercial, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.entreprise_raison_sociale, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.entreprise_siret_siege_social, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.entreprise_nom, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.entreprise_prenom, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.association_rna, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.association_titre, ''::character varying))::text) || ' '::text) || COALESCE(etablissements.association_objet, ''::text)) || ' '::text) || (COALESCE(etablissements.siret, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.naf, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.libelle_naf, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.adresse, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.code_postal, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.localite, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.code_insee_localite, ''::character varying))::text) || ' '::text) || (COALESCE(individuals.nom, ''::character varying))::text) || ' '::text) || (COALESCE(individuals.prenom, ''::character varying))::text) || ' '::text) || (COALESCE(pieces_justificatives.content, ''::character varying))::text) AS term - FROM ((((((((dossiers + (((((((((((((((((((((((((((((((((((((((((((((((((((((COALESCE(users.email, ''::character varying))::text || ' '::text) || (COALESCE(france_connect_informations.given_name, ''::character varying))::text) || ' '::text) || (COALESCE(france_connect_informations.family_name, ''::character varying))::text) || ' '::text) || (COALESCE(champs.value, ''::character varying))::text) || ' '::text) || (COALESCE(drop_down_lists.value, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.entreprise_siren, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.entreprise_numero_tva_intracommunautaire, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.entreprise_forme_juridique, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.entreprise_forme_juridique_code, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.entreprise_nom_commercial, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.entreprise_raison_sociale, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.entreprise_siret_siege_social, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.entreprise_nom, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.entreprise_prenom, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.association_rna, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.association_titre, ''::character varying))::text) || ' '::text) || COALESCE(etablissements.association_objet, ''::text)) || ' '::text) || (COALESCE(etablissements.siret, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.naf, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.libelle_naf, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.adresse, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.code_postal, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.localite, ''::character varying))::text) || ' '::text) || (COALESCE(etablissements.code_insee_localite, ''::character varying))::text) || ' '::text) || (COALESCE(individuals.nom, ''::character varying))::text) || ' '::text) || (COALESCE(individuals.prenom, ''::character varying))::text) || ' '::text) || (COALESCE(pieces_justificatives.content, ''::character varying))::text) AS term + FROM (((((((dossiers JOIN users ON ((users.id = dossiers.user_id))) LEFT JOIN france_connect_informations ON ((france_connect_informations.user_id = dossiers.user_id))) - LEFT JOIN cerfas ON ((cerfas.dossier_id = dossiers.id))) LEFT JOIN champs ON ((champs.dossier_id = dossiers.id))) LEFT JOIN drop_down_lists ON ((drop_down_lists.type_de_champ_id = champs.type_de_champ_id))) LEFT JOIN etablissements ON ((etablissements.dossier_id = dossiers.id))) diff --git a/db/views/searches_v04.sql b/db/views/searches_v04.sql new file mode 100644 index 000000000..f628d2f20 --- /dev/null +++ b/db/views/searches_v04.sql @@ -0,0 +1,39 @@ +-- this version merges all possible search terms together, complicating the +-- view, but enables searching for multiple terms from multiple tables at once. + +SELECT dossiers.id AS dossier_id, + COALESCE(users.email, '') || ' ' || + COALESCE(france_connect_informations.given_name, '') || ' ' || + COALESCE(france_connect_informations.family_name, '') || ' ' || + COALESCE(champs.value, '') || ' ' || + COALESCE(drop_down_lists.value, '') || ' ' || + COALESCE(etablissements.entreprise_siren, '') || ' ' || + COALESCE(etablissements.entreprise_numero_tva_intracommunautaire, '') || ' ' || + COALESCE(etablissements.entreprise_forme_juridique, '') || ' ' || + COALESCE(etablissements.entreprise_forme_juridique_code, '') || ' ' || + COALESCE(etablissements.entreprise_nom_commercial, '') || ' ' || + COALESCE(etablissements.entreprise_raison_sociale, '') || ' ' || + COALESCE(etablissements.entreprise_siret_siege_social, '') || ' ' || + COALESCE(etablissements.entreprise_nom, '') || ' ' || + COALESCE(etablissements.entreprise_prenom, '') || ' ' || + COALESCE(etablissements.association_rna, '') || ' ' || + COALESCE(etablissements.association_titre, '') || ' ' || + COALESCE(etablissements.association_objet, '') || ' ' || + COALESCE(etablissements.siret, '') || ' ' || + COALESCE(etablissements.naf, '') || ' ' || + COALESCE(etablissements.libelle_naf, '') || ' ' || + COALESCE(etablissements.adresse, '') || ' ' || + COALESCE(etablissements.code_postal, '') || ' ' || + COALESCE(etablissements.localite, '') || ' ' || + COALESCE(etablissements.code_insee_localite, '') || ' ' || + COALESCE(individuals.nom, '') || ' ' || + COALESCE(individuals.prenom, '') || ' ' || + COALESCE(pieces_justificatives.content, '') AS term +FROM dossiers +INNER JOIN users ON users.id = dossiers.user_id +LEFT JOIN france_connect_informations ON france_connect_informations.user_id = dossiers.user_id +LEFT JOIN champs ON champs.dossier_id = dossiers.id +LEFT JOIN drop_down_lists ON drop_down_lists.type_de_champ_id = champs.type_de_champ_id +LEFT JOIN etablissements ON etablissements.dossier_id = dossiers.id +LEFT JOIN individuals ON individuals.dossier_id = dossiers.id +LEFT JOIN pieces_justificatives ON pieces_justificatives.dossier_id = dossiers.id diff --git a/spec/controllers/admin/procedures_controller_spec.rb b/spec/controllers/admin/procedures_controller_spec.rb index 58b11f98f..33819ca8a 100644 --- a/spec/controllers/admin/procedures_controller_spec.rb +++ b/spec/controllers/admin/procedures_controller_spec.rb @@ -11,11 +11,10 @@ describe Admin::ProceduresController, type: :controller do let(:organisation) { 'Organisation de test' } let(:direction) { 'Direction de test' } let(:lien_demarche) { 'http://localhost.com' } + let(:cadre_juridique) { 'cadre juridique' } let(:use_api_carto) { '0' } let(:quartiers_prioritaires) { '0' } let(:cadastre) { '0' } - let(:cerfa_flag) { true } - let(:cadre_juridique) { 'cadre juridique' } let(:duree_conservation_dossiers_dans_ds) { 3 } let(:duree_conservation_dossiers_hors_ds) { 6 } @@ -26,7 +25,6 @@ describe Admin::ProceduresController, type: :controller do organisation: organisation, direction: direction, lien_demarche: lien_demarche, - cerfa_flag: cerfa_flag, cadre_juridique: cadre_juridique, duree_conservation_dossiers_dans_ds: duree_conservation_dossiers_dans_ds, duree_conservation_dossiers_hors_ds: duree_conservation_dossiers_hors_ds, @@ -328,7 +326,6 @@ describe Admin::ProceduresController, type: :controller do it { expect(subject.organisation).to eq procedure_params[:organisation] } it { expect(subject.direction).to eq procedure_params[:direction] } - it { expect(subject.cerfa_flag).not_to eq procedure_params[:cerfa_flag] } it { expect(subject.lien_demarche).not_to eq procedure_params[:lien_demarche] } it { expect(subject.for_individual).not_to eq procedure_params[:for_individual] } it { expect(subject.individual_with_siret).not_to eq procedure_params[:individual_with_siret] } diff --git a/spec/controllers/api/v1/dossiers_controller_spec.rb b/spec/controllers/api/v1/dossiers_controller_spec.rb index 99b83e973..44ff98fad 100644 --- a/spec/controllers/api/v1/dossiers_controller_spec.rb +++ b/spec/controllers/api/v1/dossiers_controller_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe API::V1::DossiersController do let(:admin) { create(:administrateur) } - let(:procedure) { create(:procedure, :with_two_type_de_piece_justificative, :with_type_de_champ, :with_type_de_champ_private, administrateur: admin, cerfa_flag: true) } + let(:procedure) { create(:procedure, :with_two_type_de_piece_justificative, :with_type_de_champ, :with_type_de_champ_private, administrateur: admin) } let(:wrong_procedure) { create(:procedure) } it { expect(described_class).to be < APIController } @@ -332,34 +332,6 @@ describe API::V1::DossiersController do it { expect(subject.first[:email]).to eq 'plop@plip.com' } end - describe 'cerfa', vcr: { cassette_name: 'controllers_api_v1_dossiers_controller_cerfa' } do - let!(:dossier) { Timecop.freeze(date_creation) { create(:dossier, :with_entreprise, :with_cerfa_upload, procedure: procedure) } } - let(:content) { File.open('./spec/support/files/piece_justificative_388.pdf') } - - before do - tmp_cerfa = dossier.cerfa.first - tmp_cerfa.content = content - tmp_cerfa.user = dossier.user - tmp_cerfa.save - end - - subject { super()[:cerfa].first } - - it { expect(subject[:created_at]).not_to be_nil } - if Flipflop.remote_storage? - it { expect(subject[:content_url]).to match(/^https:\/\/storage.apientreprise.fr\/tps_dev\/cerfa-.*\.pdf$/) } - else - it { expect(subject[:content_url]).to match(/^http:\/\/.*downloads.*_CERFA\.pdf$/) } - end - - describe 'user' do - let(:field_list) { [:url, :created_at, :type_de_piece_justificative_id] } - subject { super()[:user] } - - it { expect(subject[:email]).not_to be_nil } - end - end - describe 'etablissement' do let(:field_list) { [ diff --git a/spec/controllers/users/description_controller_shared_example.rb b/spec/controllers/users/description_controller_shared_example.rb index f9d8f755b..04145cde8 100644 --- a/spec/controllers/users/description_controller_shared_example.rb +++ b/spec/controllers/users/description_controller_shared_example.rb @@ -190,61 +190,6 @@ shared_examples 'description_controller_spec' do end end - context 'Quand la procédure accepte les CERFA' do - subject { post :update, params: { dossier_id: dossier_id, cerfa_pdf: cerfa_pdf } } - - context 'Sauvegarde du CERFA PDF', vcr: { cassette_name: 'controllers_users_description_controller_save_cerfa' } do - before do - post :update, params: { dossier_id: dossier_id, cerfa_pdf: cerfa_pdf } - dossier.reload - end - - context 'when a CERFA PDF is sent', vcr: { cassette_name: 'controllers_users_description_controller_cerfa_is_sent' } do - subject { dossier.cerfa.first } - - it 'content' do - if Flipflop.remote_storage? - expect(subject['content']).to eq('cerfa-3dbb3535-5388-4a37-bc2d-778327b9f999.pdf') - else - expect(subject['content']).to eq('cerfa.pdf') - end - end - - it 'dossier_id' do - expect(subject.dossier_id).to eq(dossier_id) - end - - it { expect(subject.user).to eq user } - end - - context 'les anciens CERFA PDF ne sont pas écrasées' do - let(:cerfas) { Cerfa.where(dossier_id: dossier_id) } - - before do - post :update, params: { dossier_id: dossier_id, cerfa_pdf: cerfa_pdf } - end - - it "il y a deux CERFA PDF pour ce dossier" do - expect(cerfas.size).to eq 2 - end - end - end - end - - context 'Quand la procédure n\'accepte pas les CERFA' do - context 'Sauvegarde du CERFA PDF' do - let!(:procedure) { create(:procedure) } - before do - post :update, params: { dossier_id: dossier_id, cerfa_pdf: cerfa_pdf } - dossier.reload - end - - context 'un CERFA PDF est envoyé' do - it { expect(dossier.cerfa_available?).to be_falsey } - end - end - end - describe 'Sauvegarde des champs' do let(:champs_dossier) { dossier.champs } let(:dossier_text_value) { 'test value' } @@ -288,7 +233,7 @@ shared_examples 'description_controller_spec' do it { expect(response).to redirect_to users_dossier_recapitulatif_path } context 'when champs is mandatory' do - let(:procedure) { create(:procedure, :with_two_type_de_piece_justificative, :with_type_de_champ_mandatory, :with_datetime, cerfa_flag: true) } + let(:procedure) { create(:procedure, :with_two_type_de_piece_justificative, :with_type_de_champ_mandatory, :with_datetime) } it { expect(response).not_to redirect_to users_dossier_recapitulatif_path } it { expect(flash[:alert]).to be_present } diff --git a/spec/controllers/users/description_controller_spec.rb b/spec/controllers/users/description_controller_spec.rb index 6582209e0..011560304 100644 --- a/spec/controllers/users/description_controller_spec.rb +++ b/spec/controllers/users/description_controller_spec.rb @@ -9,9 +9,9 @@ describe Users::DescriptionController, type: :controller, vcr: { cassette_name: let(:state) { 'en_construction' } let(:procedure) do if archived - create(:procedure, :archived, :with_two_type_de_piece_justificative, :with_type_de_champ, :with_datetime, cerfa_flag: true) + create(:procedure, :archived, :with_two_type_de_piece_justificative, :with_type_de_champ, :with_datetime) else - create(:procedure, :published, :with_two_type_de_piece_justificative, :with_type_de_champ, :with_datetime, cerfa_flag: true) + create(:procedure, :published, :with_two_type_de_piece_justificative, :with_type_de_champ, :with_datetime) end end let(:dossier) { create(:dossier, procedure: procedure, user: owner_user, state: state) } @@ -23,7 +23,6 @@ describe Users::DescriptionController, type: :controller, vcr: { cassette_name: let(:name_piece_justificative_0) { 'piece_justificative_0.pdf' } let(:name_piece_justificative_1) { 'piece_justificative_1.pdf' } - let(:cerfa_pdf) { Rack::Test::UploadedFile.new("./spec/support/files/#{name_piece_justificative}", 'application/pdf') } let(:piece_justificative_0) { Rack::Test::UploadedFile.new("./spec/support/files/#{name_piece_justificative_0}", 'application/pdf') } let(:piece_justificative_1) { Rack::Test::UploadedFile.new("./spec/support/files/#{name_piece_justificative_1}", 'application/pdf') } diff --git a/spec/factories/cerfa.rb b/spec/factories/cerfa.rb deleted file mode 100644 index c6ccc5bc4..000000000 --- a/spec/factories/cerfa.rb +++ /dev/null @@ -1,4 +0,0 @@ -FactoryBot.define do - factory :cerfa do - end -end diff --git a/spec/factories/dossier.rb b/spec/factories/dossier.rb index a41fed27b..09b4140fd 100644 --- a/spec/factories/dossier.rb +++ b/spec/factories/dossier.rb @@ -45,12 +45,6 @@ FactoryBot.define do end end - trait :with_cerfa_upload do - after(:build) do |dossier, _evaluator| - dossier.cerfa << create(:cerfa) - end - end - trait :archived do archived true end diff --git a/spec/factories/procedure.rb b/spec/factories/procedure.rb index 7d93b2eac..79c0eb9e0 100644 --- a/spec/factories/procedure.rb +++ b/spec/factories/procedure.rb @@ -8,7 +8,6 @@ FactoryBot.define do direction "direction DINSIC" cadre_juridique "un cadre juridique important" published_at nil - cerfa_flag false administrateur { create(:administrateur) } duree_conservation_dossiers_dans_ds 3 duree_conservation_dossiers_hors_ds 6 diff --git a/spec/features/description_page/upload_piece_justificative_spec.rb b/spec/features/description_page/upload_piece_justificative_spec.rb index 50f00c9fb..6aba555f9 100644 --- a/spec/features/description_page/upload_piece_justificative_spec.rb +++ b/spec/features/description_page/upload_piece_justificative_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' feature 'user is on description page' do - let!(:procedure) { create(:procedure, :with_two_type_de_piece_justificative, :with_type_de_champ, cerfa_flag: true) } + let!(:procedure) { create(:procedure, :with_two_type_de_piece_justificative, :with_type_de_champ) } let!(:dossier) { create(:dossier, :with_entreprise, procedure: procedure, autorisation_donnees: true) } before do @@ -23,25 +23,12 @@ feature 'user is on description page' do find_by_id("champs_#{dossier.champs.first.id}").set 'mon nom' end context 'before submit' do - it 'dossier cerfa is empty' do - expect(dossier.cerfa).to be_empty - end it 'pieces_justificatives are empty' do dossier.pieces_justificatives.each do |piece_justificative| expect(piece_justificative).to be_empty end end end - context 'he adds cerfa', vcr: { cassette_name: 'description_page_upload_piece_justificative_adds_cerfa' } do - before do - attach_file('cerfa_pdf', File.path('spec/support/files/dossierPDF.pdf')) - click_on("Soumettre mon dossier") - dossier.reload - end - it 'fills dossier cerfa' do - expect(dossier.cerfa).not_to be_empty - end - end context 'when he adds a piece_justificative and submit form', vcr: { cassette_name: 'description_page_upload_piece_justificative_adds_cerfa_and_submit' } do before do file_input_id = "piece_justificative_#{dossier.types_de_piece_justificative.first.id.to_s}" diff --git a/spec/lib/file_size_validator_spec.rb b/spec/lib/file_size_validator_spec.rb index 78d5461bb..a28b6393c 100644 --- a/spec/lib/file_size_validator_spec.rb +++ b/spec/lib/file_size_validator_spec.rb @@ -2,8 +2,8 @@ require 'spec_helper' describe FileSizeValidator, lib: true do let(:validator) { FileSizeValidator.new(options) } - let(:attachment) { CerfaUploader.new } - let(:note) { create(:cerfa) } + let(:attachment) { PieceJustificativeUploader.new } + let(:note) { create(:piece_justificative, :contrat) } describe 'options uses an integer' do let(:options) { { maximum: 10, attributes: { content: attachment } } } diff --git a/spec/models/cerfa_spec.rb b/spec/models/cerfa_spec.rb deleted file mode 100644 index f09242b6f..000000000 --- a/spec/models/cerfa_spec.rb +++ /dev/null @@ -1,15 +0,0 @@ -require 'spec_helper' - -describe Cerfa do - describe 'empty?', vcr: { cassette_name: 'models_cerfa_empty' } do - subject { create(:cerfa, content: content) } - context 'when content exist' do - let(:content) { File.open('./spec/support/files/piece_justificative_388.pdf') } - it { expect(subject).not_to be_empty } - end - context 'when content is nil' do - let(:content) { nil } - it { expect(subject).to be_empty } - end - end -end diff --git a/spec/models/champs/linked_drop_down_list_champ_spec.rb b/spec/models/champs/linked_drop_down_list_champ_spec.rb index 95327e5cb..70ec18108 100644 --- a/spec/models/champs/linked_drop_down_list_champ_spec.rb +++ b/spec/models/champs/linked_drop_down_list_champ_spec.rb @@ -15,4 +15,87 @@ describe Champs::LinkedDropDownListChamp do it { expect(champ.value).to eq('["tata","tutu"]') } end + + describe '#for_display' do + let(:champ) { described_class.new(primary_value: primary_value, secondary_value: secondary_value) } + let(:primary_value) { nil } + let(:secondary_value) { nil } + + subject { champ.for_display } + + context 'with no value' do + it { is_expected.to eq('') } + end + + context 'with primary value' do + let(:primary_value) { 'primary' } + + it { is_expected.to eq('primary') } + end + + context 'with secondary value' do + let(:primary_value) { 'primary' } + let(:secondary_value) { 'secondary' } + + it { is_expected.to eq('primary / secondary') } + end + end + + describe 'for_export' do + subject { champ.for_export } + + context 'with no value' do + let(:champ) { described_class.new } + + it { is_expected.to be_nil } + end + + context 'with primary value' do + let(:champ) { described_class.new(primary_value: 'primary') } + + it { is_expected.to eq('primary;') } + end + + context 'with secondary value' do + let(:champ) { described_class.new(primary_value: 'primary', secondary_value: 'secondary') } + + it { is_expected.to eq('primary;secondary') } + end + end + + describe '#mandatory_and_blank' do + let(:drop_down_list) { build(:drop_down_list, value: "--Primary--\nSecondary") } + + subject { described_class.new(type_de_champ: type_de_champ) } + + context 'when the champ is not mandatory' do + let(:type_de_champ) { build(:type_de_champ_linked_drop_down_list, drop_down_list: drop_down_list) } + + it 'blank is fine' do + is_expected.not_to be_mandatory_and_blank + end + end + + context 'when the champ is mandatory' do + let(:type_de_champ) { build(:type_de_champ_linked_drop_down_list, mandatory: true, drop_down_list: drop_down_list) } + + context 'when there is no value' do + it { is_expected.to be_mandatory_and_blank } + end + + context 'when there is a primary value' do + before { subject.primary_value = 'Primary' } + + context 'when there is no secondary value' do + it { is_expected.to be_mandatory_and_blank } + end + + context 'when there is a secondary value' do + before { subject.secondary_value = 'Primary' } + + it { is_expected.not_to be_mandatory_and_blank } + end + end + end + end end diff --git a/spec/models/dossier_spec.rb b/spec/models/dossier_spec.rb index f2d774417..cebaea315 100644 --- a/spec/models/dossier_spec.rb +++ b/spec/models/dossier_spec.rb @@ -41,31 +41,6 @@ describe Dossier do end end - describe 'creation' do - describe 'Procedure accepts cerfa upload' do - let(:procedure) { create(:procedure, cerfa_flag: true) } - let(:dossier) { create(:dossier, :with_entreprise, procedure: procedure, user: user) } - it 'create default cerfa' do - expect { subject.to change(Cerfa.count).by(1) } - expect { subject.cerfa_available.to be_truthy } - end - - it 'link cerfa to dossier' do - expect { subject.cerfa.to eq(Cerfa.last) } - end - end - - describe 'Procedure does not accept cerfa upload' do - let(:procedure) { create(:procedure, cerfa_flag: false) } - let(:dossier) { create(:dossier, :with_entreprise, user: user) } - it 'default cerfa is not created' do - expect { subject.to change(Cerfa.count).by(0) } - expect { subject.cerfa.to eq(nil) } - expect { subject.cerfa_available.to be_falsey } - end - end - end - describe '#retrieve_last_piece_justificative_by_type', vcr: { cassette_name: 'models_dossier_retrieve_last_piece_justificative_by_type' } do let(:types_de_pj_dossier) { dossier.procedure.types_de_piece_justificative } @@ -133,26 +108,6 @@ describe Dossier do end end - describe '#cerfa_available?' do - let(:procedure) { create(:procedure, cerfa_flag: cerfa_flag) } - let(:dossier) { create(:dossier, procedure: procedure) } - - context 'Procedure accepts CERFA' do - let(:cerfa_flag) { true } - context 'when cerfa is not uploaded' do - it { expect(dossier.cerfa_available?).to be_falsey } - end - context 'when cerfa is uploaded' do - let(:dossier) { create :dossier, :with_cerfa_upload, procedure: procedure } - it { expect(dossier.cerfa_available?).to be_truthy } - end - end - context 'Procedure does not accept CERFA' do - let(:cerfa_flag) { false } - it { expect(dossier.cerfa_available?).to be_falsey } - end - end - describe '#convert_specific_hash_values_to_string(hash_to_convert)' do let(:procedure) { create(:procedure) } let(:dossier) { create(:dossier, :with_entreprise, user: user, procedure: procedure) } @@ -746,12 +701,6 @@ describe Dossier do it { is_expected.not_to eq(modif_date) } - context 'when a cerfa is modified' do - before { dossier.cerfa << create(:cerfa) } - - it { is_expected.to eq(modif_date) } - end - context 'when a piece justificative is modified' do before { dossier.pieces_justificatives << create(:piece_justificative, :contrat) } diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index f532af613..e04cac0f7 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -116,7 +116,6 @@ RSpec.configure do |config| config.before(:each) do allow_any_instance_of(PieceJustificativeUploader).to receive(:generate_secure_token).and_return("3dbb3535-5388-4a37-bc2d-778327b9f997") allow_any_instance_of(ProcedureLogoUploader).to receive(:generate_secure_token).and_return("3dbb3535-5388-4a37-bc2d-778327b9f998") - allow_any_instance_of(CerfaUploader).to receive(:generate_secure_token).and_return("3dbb3535-5388-4a37-bc2d-778327b9f999") end config.before(:all) { diff --git a/spec/views/users/description/show.html.haml_spec.rb b/spec/views/users/description/show.html.haml_spec.rb index afe24dc62..ca1a0f3fd 100644 --- a/spec/views/users/description/show.html.haml_spec.rb +++ b/spec/views/users/description/show.html.haml_spec.rb @@ -2,8 +2,7 @@ require 'spec_helper' describe 'users/description/show.html.haml', type: :view do let(:user) { create(:user) } - let(:cerfa_flag) { true } - let(:procedure) { create(:procedure, :with_two_type_de_piece_justificative, :with_type_de_champ, :with_datetime, cerfa_flag: cerfa_flag) } + let(:procedure) { create(:procedure, :with_two_type_de_piece_justificative, :with_type_de_champ, :with_datetime) } let(:dossier) { create(:dossier, procedure: procedure, user: user) } let(:dossier_id) { dossier.id } @@ -21,14 +20,6 @@ describe 'users/description/show.html.haml', type: :view do it 'Le formulaire envoie vers /users/dossiers/:dossier_id/description en #POST' do expect(rendered).to have_selector("form[action='/users/dossiers/#{dossier_id}/description'][method=post]") end - - it 'Charger votre CERFA (PDF)' do - expect(rendered).to have_selector('input[type=file][name=cerfa_pdf][id=cerfa_pdf]') - end - - it 'Lien CERFA' do - expect(rendered).to have_selector('#lien_cerfa') - end end context 'si la page précédente n\'est pas recapitulatif' do @@ -102,17 +93,6 @@ describe 'users/description/show.html.haml', type: :view do end end - context 'Envoi des CERFA désactivé' do - let!(:cerfa_flag) { false } - - before do - render - end - - it { expect(rendered).to_not have_css("#cerfa_flag") } - it { expect(rendered).to_not have_selector('input[type=file][name=cerfa_pdf][id=cerfa_pdf]') } - end - describe 'display title Documents administratifs' do before do render @@ -121,7 +101,7 @@ describe 'users/description/show.html.haml', type: :view do let(:procedure) { create :procedure, lien_demarche: '' } let(:dossier) { create(:dossier, procedure: procedure) } - context 'when dossier not have cerfa, piece justificative and demarche link' do + context 'when dossier not have piece justificative and demarche link' do it { expect(rendered).not_to have_content 'Documents administratifs' } end end