add api_entreprise to piece_jointe

This commit is contained in:
Tanguy PATTE 2015-08-18 16:44:16 +02:00
parent 1f960a4b43
commit f49477dee7
3 changed files with 24 additions and 1 deletions

View file

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

View file

@ -0,0 +1,5 @@
FactoryGirl.define do
factory :type_piece_jointe do
end
end

View file

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