add empty to piece_jointe
This commit is contained in:
parent
f49477dee7
commit
bda3a410c4
2 changed files with 15 additions and 8 deletions
|
@ -5,13 +5,7 @@ class PieceJointe < ActiveRecord::Base
|
|||
mount_uploader :content, PieceJointeUploader
|
||||
|
||||
|
||||
# TODO: remove this function, find another way
|
||||
def self.get_array_id_pj_valid_for_dossier(dossier_id)
|
||||
@array_id_pj_valides = []
|
||||
where(dossier_id: dossier_id).each do |pj_valide|
|
||||
@array_id_pj_valides << pj_valide.type_piece_jointe_id
|
||||
end
|
||||
|
||||
@array_id_pj_valides
|
||||
def empty?
|
||||
content.blank?
|
||||
end
|
||||
end
|
||||
|
|
|
@ -27,4 +27,17 @@ describe PieceJointe do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#empty?' do
|
||||
let(:piece_jointe) { create(:piece_jointe, content: content) }
|
||||
subject { piece_jointe.empty? }
|
||||
context 'when content is nil' do
|
||||
let(:content) { nil }
|
||||
it { is_expected.to be_truthy }
|
||||
end
|
||||
context 'when content exist' do
|
||||
let(:content) { File.open('./spec/support/files/piece_jointe_388.pdf') }
|
||||
it { is_expected.to be_falsey }
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue