models: remove old pieces justificatives
This commit is contained in:
parent
212d1f8cea
commit
95e24392f9
8 changed files with 0 additions and 7976 deletions
|
@ -1,56 +0,0 @@
|
|||
class PieceJustificative < ApplicationRecord
|
||||
belongs_to :dossier, inverse_of: :pieces_justificatives, touch: true
|
||||
belongs_to :type_de_piece_justificative
|
||||
has_one :commentaire
|
||||
|
||||
belongs_to :user
|
||||
|
||||
delegate :api_entreprise, :libelle, :order_place, to: :type_de_piece_justificative
|
||||
|
||||
alias_attribute :type, :type_de_piece_justificative_id
|
||||
|
||||
mount_uploader :content, PieceJustificativeUploader
|
||||
validates :content, :file_size => { :maximum => 20.megabytes }
|
||||
validates :content, presence: true, allow_blank: false, allow_nil: false
|
||||
|
||||
scope :updated_since?, -> (date) { where('pieces_justificatives.updated_at > ?', date) }
|
||||
|
||||
def empty?
|
||||
content.blank?
|
||||
end
|
||||
|
||||
def libelle
|
||||
if type_de_piece_justificative.nil?
|
||||
return content.to_s
|
||||
else
|
||||
type_de_piece_justificative.libelle
|
||||
end
|
||||
end
|
||||
|
||||
def content_url
|
||||
if content.url.present?
|
||||
if Flipflop.remote_storage?
|
||||
(RemoteDownloader.new content.filename).url
|
||||
else
|
||||
(LocalDownloader.new content.path,
|
||||
(type_de_piece_justificative.nil? ? content.original_filename : type_de_piece_justificative.libelle)).url
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def self.accept_format
|
||||
" application/pdf,
|
||||
application/msword,
|
||||
application/vnd.openxmlformats-officedocument.wordprocessingml.document,
|
||||
application/vnd.ms-excel,
|
||||
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,
|
||||
application/vnd.ms-powerpoint,
|
||||
application/vnd.openxmlformats-officedocument.presentationml.presentation,
|
||||
application/vnd.oasis.opendocument.text,
|
||||
application/vnd.oasis.opendocument.presentation,
|
||||
application/vnd.oasis.opendocument.spreadsheet,
|
||||
image/png,
|
||||
image/jpeg
|
||||
"
|
||||
end
|
||||
end
|
|
@ -1,10 +0,0 @@
|
|||
class TypeDePieceJustificative < ApplicationRecord
|
||||
has_many :pieces_justificatives, dependent: :destroy
|
||||
|
||||
belongs_to :procedure
|
||||
|
||||
validates :libelle, presence: true, allow_blank: false, allow_nil: false
|
||||
|
||||
validates :lien_demarche, format: { with: URI.regexp }, allow_blank: true, allow_nil: true
|
||||
scope :ordered, -> { order(order_place: :asc) }
|
||||
end
|
|
@ -10,8 +10,6 @@ ActiveSupport::Inflector.inflections(:en) do |inflect|
|
|||
# inflect.uncountable %w( fish sheep )
|
||||
inflect.acronym 'API'
|
||||
inflect.acronym 'RNA'
|
||||
inflect.irregular 'piece_justificative', 'pieces_justificatives'
|
||||
inflect.irregular 'type_de_piece_justificative', 'types_de_piece_justificative'
|
||||
inflect.irregular 'type_de_champ', 'types_de_champ'
|
||||
inflect.irregular 'type_de_champ_private', 'types_de_champ_private'
|
||||
inflect.irregular 'assign_to', 'assign_tos'
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
FactoryBot.define do
|
||||
factory :piece_justificative do
|
||||
trait :rib do
|
||||
content { Rack::Test::UploadedFile.new("./spec/fixtures/files/RIB.pdf", 'application/pdf') }
|
||||
end
|
||||
|
||||
trait :contrat do
|
||||
content { Rack::Test::UploadedFile.new("./spec/fixtures/files/Contrat.pdf", 'application/pdf') }
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,18 +0,0 @@
|
|||
FactoryBot.define do
|
||||
factory :type_de_piece_justificative do
|
||||
libelle { 'RIB' }
|
||||
description { 'Releve identité bancaire' }
|
||||
|
||||
trait :rib do
|
||||
libelle { 'RIB' }
|
||||
description { 'Releve identité bancaire' }
|
||||
api_entreprise { false }
|
||||
end
|
||||
|
||||
trait :msa do
|
||||
libelle { 'Attestation MSA' }
|
||||
description { 'recuperation automatique' }
|
||||
api_entreprise { true }
|
||||
end
|
||||
end
|
||||
end
|
7833
spec/fixtures/cassettes/model_piece_justificative.yml
vendored
7833
spec/fixtures/cassettes/model_piece_justificative.yml
vendored
File diff suppressed because it is too large
Load diff
|
@ -1,20 +0,0 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe PieceJustificative do
|
||||
describe 'validations' do
|
||||
context 'content' do
|
||||
it { is_expected.not_to allow_value(nil).for(:content) }
|
||||
it { is_expected.not_to allow_value('').for(:content) }
|
||||
end
|
||||
end
|
||||
|
||||
describe '#empty?', vcr: { cassette_name: 'model_piece_justificative' } do
|
||||
let(:piece_justificative) { create(:piece_justificative, content: content) }
|
||||
subject { piece_justificative.empty? }
|
||||
|
||||
context 'when content exist' do
|
||||
let(:content) { File.open('./spec/fixtures/files/piece_justificative_388.pdf') }
|
||||
it { is_expected.to be_falsey }
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,26 +0,0 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe TypeDePieceJustificative do
|
||||
let!(:procedure) { create(:procedure) }
|
||||
|
||||
describe 'validation' do
|
||||
context 'libelle' do
|
||||
it { is_expected.not_to allow_value(nil).for(:libelle) }
|
||||
it { is_expected.not_to allow_value('').for(:libelle) }
|
||||
it { is_expected.to allow_value('RIB').for(:libelle) }
|
||||
end
|
||||
|
||||
context 'order_place' do
|
||||
# it { is_expected.not_to allow_value(nil).for(:order_place) }
|
||||
# it { is_expected.not_to allow_value('').for(:order_place) }
|
||||
it { is_expected.to allow_value(1).for(:order_place) }
|
||||
end
|
||||
|
||||
context 'lien_demarche' do
|
||||
it { is_expected.to allow_value(nil).for(:lien_demarche) }
|
||||
it { is_expected.to allow_value('').for(:lien_demarche) }
|
||||
it { is_expected.not_to allow_value('not-a-link').for(:lien_demarche) }
|
||||
it { is_expected.to allow_value('http://link').for(:lien_demarche) }
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue