delegate libelle do type piece jointe

This commit is contained in:
Tanguy PATTE 2015-08-18 17:00:09 +02:00
parent bda3a410c4
commit 92e522eb3d
2 changed files with 4 additions and 17 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
delegate :api_entreprise, :libelle, to: :type_piece_jointe
mount_uploader :content, PieceJointeUploader

View file

@ -10,22 +10,9 @@ describe PieceJointe do
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
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) }
end
describe '#empty?' do