2015-05-21 23:10:59 -07:00
|
|
|
require_relative '../environment.rb'
|
|
|
|
|
|
|
|
describe ArchiveWorker do
|
|
|
|
it 'stores an IPFS archive' do
|
|
|
|
return if ENV['TRAVIS']
|
|
|
|
site = Fabricate :site
|
|
|
|
ipfs_hash = site.add_to_ipfs
|
|
|
|
ArchiveWorker.new.perform site.id
|
2022-08-10 14:31:36 -05:00
|
|
|
_(site.archives.length).must_equal 1
|
2015-05-21 23:10:59 -07:00
|
|
|
archive_one = site.archives.first
|
2022-08-10 14:31:36 -05:00
|
|
|
_(archive_one.ipfs_hash).must_equal ipfs_hash
|
|
|
|
_(archive_one.updated_at).wont_be_nil
|
2015-05-21 23:10:59 -07:00
|
|
|
|
|
|
|
new_updated_at = Time.now - 500
|
|
|
|
archive_one.update updated_at: new_updated_at
|
|
|
|
|
|
|
|
ArchiveWorker.new.perform site.id
|
2022-08-10 14:31:36 -05:00
|
|
|
_(archive_one.reload.updated_at).wont_equal new_updated_at
|
2015-05-21 23:10:59 -07:00
|
|
|
|
|
|
|
site.store_files [{filename: 'test.jpg', tempfile: Rack::Test::UploadedFile.new('./tests/files/test.jpg', 'image/jpeg')}]
|
|
|
|
ArchiveWorker.new.perform site.id
|
|
|
|
|
|
|
|
site.reload
|
2022-08-10 14:31:36 -05:00
|
|
|
_(site.archives.length).must_equal 2
|
2015-05-21 23:10:59 -07:00
|
|
|
archive_two = site.archives_dataset.exclude(ipfs_hash: archive_one.ipfs_hash).first
|
2022-08-10 14:31:36 -05:00
|
|
|
_(archive_two.ipfs_hash).wont_be_nil
|
2015-05-21 23:10:59 -07:00
|
|
|
end
|
|
|
|
end
|