diff --git a/app/models/piece_jointe.rb b/app/models/piece_jointe.rb index 09bdedba1..90ce1798f 100644 --- a/app/models/piece_jointe.rb +++ b/app/models/piece_jointe.rb @@ -1,7 +1,7 @@ class PieceJointe < ActiveRecord::Base belongs_to :dossier belongs_to :type_piece_jointe - + delegate :api_entreprise, to: :type_piece_jointe mount_uploader :content, PieceJointeUploader diff --git a/spec/factories/type_piece_jointe.rb b/spec/factories/type_piece_jointe.rb new file mode 100644 index 000000000..19ad7d1c8 --- /dev/null +++ b/spec/factories/type_piece_jointe.rb @@ -0,0 +1,5 @@ +FactoryGirl.define do + factory :type_piece_jointe do + + end +end \ No newline at end of file diff --git a/spec/models/piece_jointe_spec.rb b/spec/models/piece_jointe_spec.rb index 29c580cb5..a0c1456cb 100644 --- a/spec/models/piece_jointe_spec.rb +++ b/spec/models/piece_jointe_spec.rb @@ -9,4 +9,22 @@ describe PieceJointe do it { is_expected.to belong_to(:dossier) } it { is_expected.to belong_to(:type_piece_jointe) } end + + describe 'api_entreprise' do + let(:type_piece_jointe) { create(:type_piece_jointe, api_entreprise: api_entreprise)} + let(:piece_jointe) { create(:piece_jointe, type_piece_jointe: type_piece_jointe)} + subject { piece_jointe.api_entreprise } + context 'when type_piece_jointe api_entreprise is true' do + let(:api_entreprise) { true } + it 'returns true' do + expect(subject).to be_truthy + end + end + context 'when type_piece_jointe api_entreprise is false' do + let(:api_entreprise) { false } + it 'returns false' do + expect(subject).to be_falsey + end + end + end end \ No newline at end of file