demarches-normaliennes/spec/models/piece_justificative_spec.rb

34 lines
1 KiB
Ruby
Raw Normal View History

require 'spec_helper'
describe PieceJustificative do
describe 'database columns' do
it { is_expected.to have_db_column(:content) }
it { is_expected.to have_db_column(:created_at) }
end
describe 'associations' do
it { is_expected.to belong_to(:dossier) }
it { is_expected.to belong_to(:type_de_piece_justificative) }
it { is_expected.to belong_to(:user) }
end
2015-08-18 16:44:16 +02:00
2015-08-18 17:00:09 +02:00
describe 'delegation' do
it { is_expected.to delegate_method(:libelle).to(:type_de_piece_justificative) }
it { is_expected.to delegate_method(:api_entreprise).to(:type_de_piece_justificative) }
2015-08-18 16:44:16 +02:00
end
2015-08-18 16:51:57 +02:00
describe '#empty?' do
let(:piece_justificative) { create(:piece_justificative, content: content) }
subject { piece_justificative.empty? }
2015-08-18 16:51:57 +02:00
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_justificative_388.pdf') }
2015-08-18 16:51:57 +02:00
it { is_expected.to be_falsey }
end
end
2015-08-20 17:30:17 +02:00
end