2017-12-06 06:36:11 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2018-02-02 08:59:43 -05:00
|
|
|
IDENTIFIER = %r{\h+/\S+}
|
|
|
|
|
2017-12-06 06:36:11 -05:00
|
|
|
describe NamespaceFileUploader do
|
|
|
|
let(:group) { build_stubbed(:group) }
|
|
|
|
let(:uploader) { described_class.new(group) }
|
2018-02-02 08:59:43 -05:00
|
|
|
let(:upload) { create(:upload, :namespace_upload, model: group) }
|
|
|
|
|
|
|
|
subject { uploader }
|
2017-12-06 06:36:11 -05:00
|
|
|
|
2018-02-02 08:59:43 -05:00
|
|
|
it_behaves_like 'builds correct paths',
|
|
|
|
store_dir: %r[uploads/-/system/namespace/\d+],
|
|
|
|
upload_path: IDENTIFIER,
|
|
|
|
absolute_path: %r[#{CarrierWave.root}/uploads/-/system/namespace/\d+/#{IDENTIFIER}]
|
|
|
|
|
|
|
|
context "object_store is REMOTE" do
|
|
|
|
before do
|
|
|
|
stub_uploads_object_storage
|
2017-12-06 06:36:11 -05:00
|
|
|
end
|
|
|
|
|
2018-02-02 08:59:43 -05:00
|
|
|
include_context 'with storage', described_class::Store::REMOTE
|
2017-12-06 06:36:11 -05:00
|
|
|
|
2018-02-02 08:59:43 -05:00
|
|
|
it_behaves_like 'builds correct paths',
|
|
|
|
store_dir: %r[namespace/\d+/\h+],
|
|
|
|
upload_path: IDENTIFIER
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "#migrate!" do
|
|
|
|
before do
|
|
|
|
uploader.store!(fixture_file_upload(Rails.root.join('spec/fixtures/doc_sample.txt')))
|
|
|
|
stub_uploads_object_storage
|
2017-12-06 06:36:11 -05: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
|
2017-12-06 06:36:11 -05:00
|
|
|
end
|
|
|
|
end
|