add api_entreprise to piece_jointe
This commit is contained in:
parent
1f960a4b43
commit
f49477dee7
3 changed files with 24 additions and 1 deletions
|
@ -1,7 +1,7 @@
|
||||||
class PieceJointe < ActiveRecord::Base
|
class PieceJointe < ActiveRecord::Base
|
||||||
belongs_to :dossier
|
belongs_to :dossier
|
||||||
belongs_to :type_piece_jointe
|
belongs_to :type_piece_jointe
|
||||||
|
delegate :api_entreprise, to: :type_piece_jointe
|
||||||
mount_uploader :content, PieceJointeUploader
|
mount_uploader :content, PieceJointeUploader
|
||||||
|
|
||||||
|
|
||||||
|
|
5
spec/factories/type_piece_jointe.rb
Normal file
5
spec/factories/type_piece_jointe.rb
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
FactoryGirl.define do
|
||||||
|
factory :type_piece_jointe do
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
|
@ -9,4 +9,22 @@ describe PieceJointe do
|
||||||
it { is_expected.to belong_to(:dossier) }
|
it { is_expected.to belong_to(:dossier) }
|
||||||
it { is_expected.to belong_to(:type_piece_jointe) }
|
it { is_expected.to belong_to(:type_piece_jointe) }
|
||||||
end
|
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
|
end
|
Loading…
Add table
Add a link
Reference in a new issue