debian-mirror-gitlab/spec/uploaders/attachment_uploader_spec.rb

39 lines
1.1 KiB
Ruby
Raw Normal View History

2019-12-21 20:55:43 +05:30
# frozen_string_literal: true
2017-08-17 22:00:37 +05:30
require 'spec_helper'
2020-07-28 23:09:34 +05:30
RSpec.describe AttachmentUploader do
2018-03-17 18:26:18 +05:30
let(:note) { create(:note, :with_attachment) }
let(:uploader) { note.attachment }
let(:upload) { create(:upload, :attachment_upload, model: uploader.model) }
2017-08-17 22:00:37 +05:30
2018-03-17 18:26:18 +05:30
subject { uploader }
2017-08-17 22:00:37 +05:30
2018-03-17 18:26:18 +05:30
it_behaves_like 'builds correct paths',
2023-06-20 00:43:36 +05:30
store_dir: %r[uploads/-/system/note/attachment/],
upload_path: %r[uploads/-/system/note/attachment/],
absolute_path: %r[#{CarrierWave.root}/uploads/-/system/note/attachment/]
2018-05-09 12:01:36 +05:30
context "object_store is REMOTE" do
before do
stub_uploads_object_storage
end
include_context 'with storage', described_class::Store::REMOTE
it_behaves_like 'builds correct paths',
2023-06-20 00:43:36 +05:30
store_dir: %r[note/attachment/],
upload_path: %r[note/attachment/]
2018-05-09 12:01:36 +05:30
end
describe "#migrate!" do
before do
2018-11-08 19:23:39 +05:30
uploader.store!(fixture_file_upload(File.join('spec/fixtures/doc_sample.txt')))
2018-05-09 12:01:36 +05:30
stub_uploads_object_storage
end
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
end
2017-08-17 22:00:37 +05:30
end