add archive model
This commit is contained in:
parent
959026ca4f
commit
c25f3c79d9
6 changed files with 153 additions and 0 deletions
51
spec/models/archive_spec.rb
Normal file
51
spec/models/archive_spec.rb
Normal file
|
@ -0,0 +1,51 @@
|
|||
describe Dossier do
|
||||
include ActiveJob::TestHelper
|
||||
|
||||
before { Timecop.freeze(Time.zone.now) }
|
||||
after { Timecop.return }
|
||||
|
||||
let(:archive) { create(:archive) }
|
||||
|
||||
describe 'scopes' do
|
||||
describe 'staled' do
|
||||
let(:recent_archive) { create(:archive) }
|
||||
let(:staled_archive) { create(:archive, updated_at: (Archive::RETENTION_DURATION + 2).days.ago) }
|
||||
|
||||
subject do
|
||||
archive; recent_archive; staled_archive
|
||||
Archive.stale
|
||||
end
|
||||
|
||||
it { is_expected.to match_array([staled_archive]) }
|
||||
end
|
||||
end
|
||||
|
||||
describe '.status' do
|
||||
it { expect(archive.status).to eq('pending') }
|
||||
end
|
||||
|
||||
describe '#make_available!' do
|
||||
before { archive.make_available! }
|
||||
it { expect(archive.status).to eq('generated') }
|
||||
end
|
||||
|
||||
describe '#available?' do
|
||||
subject { archive.available? }
|
||||
context 'without attachment' do
|
||||
let(:archive) { create(:archive, file: nil) }
|
||||
it { is_expected.to eq(false) }
|
||||
end
|
||||
|
||||
context 'with an attachment' do
|
||||
context 'when the attachment was created but the process was not over' do
|
||||
let(:archive) { create(:archive, :pending, file: Rack::Test::UploadedFile.new('spec/fixtures/files/file.pdf', 'application/pdf')) }
|
||||
it { is_expected.to eq(false) }
|
||||
end
|
||||
|
||||
context 'when the attachment was created but the process was not over' do
|
||||
let(:archive) { create(:archive, :generated, file: Rack::Test::UploadedFile.new('spec/fixtures/files/file.pdf', 'application/pdf')) }
|
||||
it { is_expected.to eq(true) }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue