From e53c808b4220775bde8b9d16628e809da93fa28a Mon Sep 17 00:00:00 2001 From: Tanguy PATTE Date: Mon, 17 Aug 2015 11:24:09 +0200 Subject: [PATCH] add test and fix association fo type piece jointe --- app/models/type_piece_jointe.rb | 8 ++------ spec/models/type_piece_jointe_spec.rb | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+), 6 deletions(-) create mode 100644 spec/models/type_piece_jointe_spec.rb diff --git a/app/models/type_piece_jointe.rb b/app/models/type_piece_jointe.rb index 52b1b5021..4833e8896 100644 --- a/app/models/type_piece_jointe.rb +++ b/app/models/type_piece_jointe.rb @@ -1,8 +1,4 @@ class TypePieceJointe < ActiveRecord::Base - - # TODO: test this methods - def self.get_liste_piece_jointe(formulaire) - where ("\"CERFA\" = '#{formulaire.demarche_id}'") - end - + has_many :pieces_jointes + belongs_to :formulaire end diff --git a/spec/models/type_piece_jointe_spec.rb b/spec/models/type_piece_jointe_spec.rb new file mode 100644 index 000000000..282a28bb5 --- /dev/null +++ b/spec/models/type_piece_jointe_spec.rb @@ -0,0 +1,22 @@ +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 \ No newline at end of file