add fonction empty for cerfa

This commit is contained in:
Tanguy PATTE 2015-08-18 16:30:57 +02:00
parent e2ff64a119
commit 1f960a4b43
3 changed files with 20 additions and 0 deletions

View file

@ -2,4 +2,8 @@ class Cerfa < ActiveRecord::Base
belongs_to :dossier belongs_to :dossier
mount_uploader :content, CerfaUploader mount_uploader :content, CerfaUploader
def empty?
content.blank?
end
end end

5
spec/factories/cerfa.rb Normal file
View file

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

View file

@ -9,4 +9,15 @@ describe Cerfa do
it { is_expected.to belong_to(:dossier) } it { is_expected.to belong_to(:dossier) }
end end
describe 'empty?' do
subject { create(:cerfa, content: content)}
context 'when content exist' do
let(:content) { File.open('./spec/support/files/piece_jointe_388.pdf') }
it { expect(subject).not_to be_empty }
end
context 'when content is nil' do
let(:content) { nil }
it { expect(subject).to be_empty }
end
end
end end