mirror of
https://github.com/neocities/neocities.git
synced 2025-08-05 01:01:30 +02:00
Implement IPFS archiving (locally). Refactor store_file.
This commit is contained in:
parent
235460abf0
commit
8424cc02e8
10 changed files with 176 additions and 90 deletions
28
tests/workers/archive_worker_tests.rb
Normal file
28
tests/workers/archive_worker_tests.rb
Normal file
|
@ -0,0 +1,28 @@
|
|||
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
|
||||
site.archives.length.must_equal 1
|
||||
archive_one = site.archives.first
|
||||
archive_one.ipfs_hash.must_equal ipfs_hash
|
||||
archive_one.updated_at.wont_be_nil
|
||||
|
||||
new_updated_at = Time.now - 500
|
||||
archive_one.update updated_at: new_updated_at
|
||||
|
||||
ArchiveWorker.new.perform site.id
|
||||
archive_one.reload.updated_at.wont_equal new_updated_at
|
||||
|
||||
site.store_files [{filename: 'test.jpg', tempfile: Rack::Test::UploadedFile.new('./tests/files/test.jpg', 'image/jpeg')}]
|
||||
ArchiveWorker.new.perform site.id
|
||||
|
||||
site.reload
|
||||
site.archives.length.must_equal 2
|
||||
archive_two = site.archives_dataset.exclude(ipfs_hash: archive_one.ipfs_hash).first
|
||||
archive_two.ipfs_hash.wont_be_nil
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue