Remove old cerfa code

This commit is contained in:
Paul Chavard 2018-04-24 16:02:36 +02:00
parent c06fa62ce4
commit d0a6957862
34 changed files with 21 additions and 440 deletions

View file

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

View file

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

View file

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

View file

@ -37,10 +37,6 @@ class DossierFacades
@dossier.procedure
end
def cerfas_ordered
@dossier.cerfa.order('created_at DESC')
end
def invites
@dossier.invites
end

View file

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

View file

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

View file

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

View file

@ -1,6 +0,0 @@
class CerfaSerializer < ActiveModel::Serializer
attributes :created_at,
:content_url
has_one :user
end

View file

@ -30,6 +30,10 @@ class DossierSerializer < ActiveModel::Serializer
champs
end
def cerfa
[]
end
def email
object.user&.email
end

View file

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

View file

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

View file

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

View file

@ -54,7 +54,7 @@
= 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 +62,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 +85,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 +115,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|

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,4 +0,0 @@
FactoryBot.define do
factory :cerfa do
end
end

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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