- Correction des tests suite à la modification du schéma de la base de données.
This commit is contained in:
parent
5f3a320f2f
commit
b3383bec9f
51 changed files with 462 additions and 585 deletions
|
@ -12,7 +12,7 @@ describe Cerfa do
|
|||
describe 'empty?' do
|
||||
subject { create(:cerfa, content: content) }
|
||||
context 'when content exist' do
|
||||
let(:content) { File.open('./spec/support/files/piece_jointe_388.pdf') }
|
||||
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
|
||||
|
|
|
@ -17,8 +17,8 @@ describe Dossier do
|
|||
end
|
||||
|
||||
describe 'associations' do
|
||||
it { is_expected.to belong_to(:formulaire) }
|
||||
it { is_expected.to have_many(:pieces_jointes) }
|
||||
it { is_expected.to belong_to(:procedure) }
|
||||
it { is_expected.to have_many(:pieces_justificatives) }
|
||||
it { is_expected.to have_many(:commentaires) }
|
||||
it { is_expected.to have_one(:cerfa) }
|
||||
it { is_expected.to have_one(:etablissement) }
|
||||
|
@ -28,7 +28,7 @@ describe Dossier do
|
|||
describe 'delegation' do
|
||||
it { is_expected.to delegate_method(:siren).to(:entreprise) }
|
||||
it { is_expected.to delegate_method(:siret).to(:etablissement) }
|
||||
it { is_expected.to delegate_method(:types_piece_jointe).to(:formulaire) }
|
||||
it { is_expected.to delegate_method(:types_de_piece_justificative).to(:procedure) }
|
||||
end
|
||||
|
||||
describe 'validation' do
|
||||
|
@ -59,18 +59,18 @@ describe Dossier do
|
|||
end
|
||||
|
||||
describe 'methods' do
|
||||
let(:dossier) { create(:dossier, :with_entreprise) }
|
||||
let(:dossier) { create(:dossier, :with_entreprise, :with_procedure) }
|
||||
|
||||
let(:entreprise) { dossier.entreprise }
|
||||
let(:etablissement) { dossier.etablissement }
|
||||
|
||||
subject { dossier }
|
||||
|
||||
describe '#types_piece_jointe' do
|
||||
subject { dossier.types_piece_jointe }
|
||||
describe '#types_de_piece_justificative' do
|
||||
subject { dossier.types_de_piece_justificative }
|
||||
it 'returns list of required piece justificative' do
|
||||
expect(subject.size).to eq(7)
|
||||
expect(subject).to include(TypePieceJointe.find(103))
|
||||
expect(subject.size).to eq(2)
|
||||
expect(subject).to include(TypeDePieceJustificative.find(TypeDePieceJustificative.first.id))
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -85,48 +85,41 @@ describe Dossier do
|
|||
end
|
||||
end
|
||||
|
||||
describe '#retrieve_piece_jointe_by_type' do
|
||||
let(:type) { 93 }
|
||||
subject { dossier.retrieve_piece_jointe_by_type type }
|
||||
describe '#retrieve_piece_justificative_by_type' do
|
||||
let(:all_dossier_pj_id){dossier.procedure.types_de_piece_justificative}
|
||||
subject { dossier.retrieve_piece_justificative_by_type all_dossier_pj_id.first }
|
||||
before do
|
||||
dossier.build_default_pieces_jointes
|
||||
dossier.build_default_pieces_justificatives
|
||||
end
|
||||
|
||||
it 'returns piece jointe with given type' do
|
||||
expect(subject.type).to eq(93)
|
||||
it 'returns piece justificative with given type' do
|
||||
expect(subject.type).to eq(all_dossier_pj_id.first.id)
|
||||
end
|
||||
end
|
||||
|
||||
describe '#build_default_pieces_jointes' do
|
||||
context 'when dossier is linked to a formulaire' do
|
||||
let(:dossier) { create(:dossier) }
|
||||
it 'build all pieces jointes needed' do
|
||||
expect(dossier.pieces_jointes.count).to eq(7)
|
||||
describe '#build_default_pieces_justificatives' do
|
||||
context 'when dossier is linked to a procedure' do
|
||||
let(:dossier) { create(:dossier, :with_procedure) }
|
||||
it 'build all pieces justificatives needed' do
|
||||
expect(dossier.pieces_justificatives.count).to eq(2)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#save' do
|
||||
subject { create(:dossier, formulaire_id: nil) }
|
||||
context 'when is linked to a formulaire' do
|
||||
it 'creates default pieces jointes' do
|
||||
expect(subject).to receive(:build_default_pieces_jointes)
|
||||
subject.update_attributes(formulaire_id: 1)
|
||||
subject { create(:dossier, procedure_id: nil) }
|
||||
context 'when is linked to a procedure' do
|
||||
it 'creates default pieces justificatives' do
|
||||
expect(subject).to receive(:build_default_pieces_justificatives)
|
||||
subject.update_attributes(procedure_id: 1)
|
||||
end
|
||||
end
|
||||
context 'when is not linked to a formulaire' do
|
||||
it 'does not create default pieces jointes' do
|
||||
expect(subject).not_to receive(:build_default_pieces_jointes)
|
||||
context 'when is not linked to a procedure' do
|
||||
it 'does not create default pieces justificatives' do
|
||||
expect(subject).not_to receive(:build_default_pieces_justificatives)
|
||||
subject.update_attributes(description: 'plop')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#mailto' do
|
||||
let(:dossier) { create(:dossier) }
|
||||
let(:email_contact) { dossier.formulaire.email_contact }
|
||||
subject { dossier.mailto }
|
||||
it { is_expected.to eq("mailto:#{email_contact}?subject=Demande%20de%20contact&body=Bonjour,%0A%0AJe%20vous%20informe%20que%20j'ai%20rempli%20le%20dossier%20sur%20TPS.%20Vous%20pouvez%20y%20acc%C3%A9der%20en%20suivant%20le%20lien%20suivant%20:%20%0Ahttps://tps-dev.apientreprise.fr/admin/dossiers/#{dossier.id}%20%0A%20Le%20num%C3%A9ro%20de%20mon%20dossier%20est%20le%20#{dossier.id}")}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,26 +0,0 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe EvenementVie do
|
||||
describe 'database column' do
|
||||
it { is_expected.to have_db_column(:nom) }
|
||||
it { is_expected.to have_db_column(:created_at) }
|
||||
it { is_expected.to have_db_column(:updated_at) }
|
||||
it { is_expected.to have_db_column(:use_admi_facile) }
|
||||
end
|
||||
|
||||
describe 'associations' do
|
||||
it { is_expected.to have_many(:formulaires) }
|
||||
end
|
||||
|
||||
describe '.for_admi_facile' do
|
||||
let(:evenement_for_admi_facile) { described_class.where(use_admi_facile: true).first }
|
||||
let(:evenement_not_for_admi_facile) { described_class.where(use_admi_facile: false).first }
|
||||
subject { described_class.for_admi_facile }
|
||||
it 'returns elements where use_admi_facile is true' do
|
||||
expect(subject).to include(evenement_for_admi_facile)
|
||||
end
|
||||
it 'does not return elements where use_admi_facile is false' do
|
||||
expect(subject).not_to include(evenement_not_for_admi_facile)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,34 +0,0 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Formulaire do
|
||||
describe 'assocations' do
|
||||
it { is_expected.to have_many(:types_piece_jointe) }
|
||||
it { is_expected.to have_many(:dossiers) }
|
||||
it { is_expected.to belong_to(:evenement_vie) }
|
||||
end
|
||||
|
||||
describe 'attributes' do
|
||||
it { is_expected.to have_db_column(:demarche_id) }
|
||||
it { is_expected.to have_db_column(:nom) }
|
||||
it { is_expected.to have_db_column(:objet) }
|
||||
it { is_expected.to have_db_column(:ministere) }
|
||||
it { is_expected.to have_db_column(:cigle_ministere) }
|
||||
it { is_expected.to have_db_column(:direction) }
|
||||
it { is_expected.to have_db_column(:evenement_vie_id) }
|
||||
it { is_expected.to have_db_column(:publics) }
|
||||
it { is_expected.to have_db_column(:lien_demarche) }
|
||||
it { is_expected.to have_db_column(:lien_fiche_signaletique) }
|
||||
it { is_expected.to have_db_column(:lien_notice) }
|
||||
it { is_expected.to have_db_column(:categorie) }
|
||||
it { is_expected.to have_db_column(:mail_pj) }
|
||||
it { is_expected.to have_db_column(:use_admi_facile) }
|
||||
it { is_expected.to have_db_column(:email_contact) }
|
||||
end
|
||||
|
||||
describe '.for_admi_facile' do
|
||||
it 'retruns Formulaire where use_admi_facile is true' do
|
||||
expect(described_class.for_admi_facile.size).to eq(described_class.where(use_admi_facile: true).count)
|
||||
expect(described_class.for_admi_facile).to include(described_class.where(use_admi_facile: true).first)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,29 +1,29 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe PieceJointe do
|
||||
describe PieceJustificative do
|
||||
describe 'database columns' do
|
||||
it { is_expected.to have_db_column(:content) }
|
||||
end
|
||||
|
||||
describe 'associations' do
|
||||
it { is_expected.to belong_to(:dossier) }
|
||||
it { is_expected.to belong_to(:type_piece_jointe) }
|
||||
it { is_expected.to belong_to(:type_de_piece_justificative) }
|
||||
end
|
||||
|
||||
describe 'delegation' do
|
||||
it { is_expected.to delegate_method(:libelle).to(:type_piece_jointe) }
|
||||
it { is_expected.to delegate_method(:api_entreprise).to(:type_piece_jointe) }
|
||||
it { is_expected.to delegate_method(:libelle).to(:type_de_piece_justificative) }
|
||||
it { is_expected.to delegate_method(:api_entreprise).to(:type_de_piece_justificative) }
|
||||
end
|
||||
|
||||
describe '#empty?' do
|
||||
let(:piece_jointe) { create(:piece_jointe, content: content) }
|
||||
subject { piece_jointe.empty? }
|
||||
let(:piece_justificative) { create(:piece_justificative, content: content) }
|
||||
subject { piece_justificative.empty? }
|
||||
context 'when content is nil' do
|
||||
let(:content) { nil }
|
||||
it { is_expected.to be_truthy }
|
||||
end
|
||||
context 'when content exist' do
|
||||
let(:content) { File.open('./spec/support/files/piece_jointe_388.pdf') }
|
||||
let(:content) { File.open('./spec/support/files/piece_justificative_388.pdf') }
|
||||
it { is_expected.to be_falsey }
|
||||
end
|
||||
end
|
16
spec/models/procedure_spec.rb
Normal file
16
spec/models/procedure_spec.rb
Normal file
|
@ -0,0 +1,16 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Procedure do
|
||||
describe 'assocations' do
|
||||
it { is_expected.to have_many(:types_de_piece_justificative) }
|
||||
it { is_expected.to have_many(:dossiers) }
|
||||
end
|
||||
|
||||
describe 'attributes' do
|
||||
it { is_expected.to have_db_column(:libelle) }
|
||||
it { is_expected.to have_db_column(:description) }
|
||||
it { is_expected.to have_db_column(:organisation) }
|
||||
it { is_expected.to have_db_column(:direction) }
|
||||
it { is_expected.to have_db_column(:test) }
|
||||
end
|
||||
end
|
16
spec/models/type_de_piece_justificative_spec.rb
Normal file
16
spec/models/type_de_piece_justificative_spec.rb
Normal file
|
@ -0,0 +1,16 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe TypeDePieceJustificative do
|
||||
describe 'database columns' do
|
||||
it { is_expected.to have_db_column(:libelle) }
|
||||
it { is_expected.to have_db_column(:description) }
|
||||
it { is_expected.to have_db_column(:api_entreprise) }
|
||||
it { is_expected.to have_db_column(:created_at) }
|
||||
it { is_expected.to have_db_column(:updated_at) }
|
||||
end
|
||||
|
||||
describe 'associations' do
|
||||
it { is_expected.to have_many(:pieces_justificatives) }
|
||||
it { is_expected.to belong_to(:procedure) }
|
||||
end
|
||||
end
|
|
@ -1,22 +0,0 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe TypePieceJointe do
|
||||
describe 'database columns' do
|
||||
it { is_expected.to have_db_column(:CERFA) }
|
||||
it { is_expected.to have_db_column(:nature) }
|
||||
it { is_expected.to have_db_column(:libelle_complet) }
|
||||
it { is_expected.to have_db_column(:libelle) }
|
||||
it { is_expected.to have_db_column(:etablissement) }
|
||||
it { is_expected.to have_db_column(:description) }
|
||||
it { is_expected.to have_db_column(:demarche) }
|
||||
it { is_expected.to have_db_column(:administration_emetrice) }
|
||||
it { is_expected.to have_db_column(:api_entreprise) }
|
||||
it { is_expected.to have_db_column(:created_at) }
|
||||
it { is_expected.to have_db_column(:updated_at) }
|
||||
end
|
||||
|
||||
describe 'associations' do
|
||||
it { is_expected.to have_many(:pieces_jointes) }
|
||||
it { is_expected.to belong_to(:formulaire) }
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue