2019-10-14 23:06:19 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-08-18 10:31:44 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-24 11:08:50 -04:00
|
|
|
RSpec.describe AttachmentUploader do
|
2018-02-02 08:59:43 -05:00
|
|
|
let(:note) { create(:note, :with_attachment) }
|
|
|
|
let(:uploader) { note.attachment }
|
|
|
|
let(:upload) { create(:upload, :attachment_upload, model: uploader.model) }
|
2016-08-18 10:31:44 -04:00
|
|
|
|
2018-02-02 08:59:43 -05:00
|
|
|
subject { uploader }
|
2017-06-07 23:32:38 -04:00
|
|
|
|
2018-02-02 08:59:43 -05:00
|
|
|
it_behaves_like 'builds correct paths',
|
|
|
|
store_dir: %r[uploads/-/system/note/attachment/],
|
|
|
|
upload_path: %r[uploads/-/system/note/attachment/],
|
|
|
|
absolute_path: %r[#{CarrierWave.root}/uploads/-/system/note/attachment/]
|
2017-06-07 23:32:38 -04:00
|
|
|
|
2018-02-02 08:59:43 -05:00
|
|
|
context "object_store is REMOTE" do
|
|
|
|
before do
|
|
|
|
stub_uploads_object_storage
|
2016-08-18 10:31:44 -04:00
|
|
|
end
|
2018-02-02 08:59:43 -05:00
|
|
|
|
|
|
|
include_context 'with storage', described_class::Store::REMOTE
|
|
|
|
|
|
|
|
it_behaves_like 'builds correct paths',
|
|
|
|
store_dir: %r[note/attachment/],
|
|
|
|
upload_path: %r[note/attachment/]
|
2016-08-18 10:31:44 -04:00
|
|
|
end
|
|
|
|
|
2018-02-02 08:59:43 -05:00
|
|
|
describe "#migrate!" do
|
|
|
|
before do
|
2018-06-05 17:18:06 -04:00
|
|
|
uploader.store!(fixture_file_upload(File.join('spec/fixtures/doc_sample.txt')))
|
2018-02-02 08:59:43 -05:00
|
|
|
stub_uploads_object_storage
|
2016-08-18 10:31:44 -04:00
|
|
|
end
|
2018-02-02 08:59:43 -05:00
|
|
|
|
|
|
|
it_behaves_like "migrates", to_store: described_class::Store::REMOTE
|
|
|
|
it_behaves_like "migrates", from_store: described_class::Store::REMOTE, to_store: described_class::Store::LOCAL
|
2016-08-18 10:31:44 -04:00
|
|
|
end
|
|
|
|
end
|