debian-mirror-gitlab/spec/tasks/gitlab/uploads/migrate_rake_spec.rb

135 lines
3.5 KiB
Ruby
Raw Normal View History

2019-12-21 20:55:43 +05:30
# frozen_string_literal: true
2018-05-09 12:01:36 +05:30
require 'rake_helper'
2021-09-04 01:27:46 +05:30
RSpec.describe 'gitlab:uploads:migrate and migrate_to_local rake tasks', :silence_stdout do
2018-05-09 12:01:36 +05:30
let(:model_class) { nil }
let(:uploader_class) { nil }
let(:mounted_as) { nil }
let(:batch_size) { 3 }
before do
2019-12-21 20:55:43 +05:30
stub_env('MIGRATION_BATCH_SIZE', batch_size.to_s)
2018-05-09 12:01:36 +05:30
stub_uploads_object_storage(uploader_class)
Rake.application.rake_require 'tasks/gitlab/uploads/migrate'
allow(ObjectStorage::MigrateUploadsWorker).to receive(:perform_async)
end
context "for AvatarUploader" do
let(:uploader_class) { AvatarUploader }
let(:mounted_as) { :avatar }
context "for Project" do
let(:model_class) { Project }
let!(:projects) { create_list(:project, 10, :with_avatar) }
2020-04-08 14:13:33 +05:30
it_behaves_like 'enqueue upload migration jobs in batch', batch: 4
2018-05-09 12:01:36 +05:30
end
context "for Group" do
let(:model_class) { Group }
before do
create_list(:group, 10, :with_avatar)
end
2020-04-08 14:13:33 +05:30
it_behaves_like 'enqueue upload migration jobs in batch', batch: 4
2018-05-09 12:01:36 +05:30
end
context "for User" do
let(:model_class) { User }
before do
create_list(:user, 10, :with_avatar)
end
2020-04-08 14:13:33 +05:30
it_behaves_like 'enqueue upload migration jobs in batch', batch: 4
2018-05-09 12:01:36 +05:30
end
end
context "for AttachmentUploader" do
let(:uploader_class) { AttachmentUploader }
context "for Note" do
let(:model_class) { Note }
let(:mounted_as) { :attachment }
before do
create_list(:note, 10, :with_attachment)
end
2020-04-08 14:13:33 +05:30
it_behaves_like 'enqueue upload migration jobs in batch', batch: 4
2018-05-09 12:01:36 +05:30
end
context "for Appearance" do
let(:model_class) { Appearance }
let(:mounted_as) { :logo }
before do
create(:appearance, :with_logos)
end
%i(logo header_logo).each do |mount|
2020-04-08 14:13:33 +05:30
it_behaves_like 'enqueue upload migration jobs in batch', batch: 1 do
2018-05-09 12:01:36 +05:30
let(:mounted_as) { mount }
end
end
end
end
context "for FileUploader" do
let(:uploader_class) { FileUploader }
let(:model_class) { Project }
before do
create_list(:project, 10) do |model|
uploader_class.new(model)
.store!(fixture_file_upload('spec/fixtures/doc_sample.txt'))
end
end
2020-04-08 14:13:33 +05:30
it_behaves_like 'enqueue upload migration jobs in batch', batch: 4
2018-05-09 12:01:36 +05:30
end
context "for PersonalFileUploader" do
let(:uploader_class) { PersonalFileUploader }
let(:model_class) { PersonalSnippet }
before do
create_list(:personal_snippet, 10) do |model|
uploader_class.new(model)
.store!(fixture_file_upload('spec/fixtures/doc_sample.txt'))
end
end
2020-04-08 14:13:33 +05:30
it_behaves_like 'enqueue upload migration jobs in batch', batch: 4
2018-05-09 12:01:36 +05:30
end
context "for NamespaceFileUploader" do
let(:uploader_class) { NamespaceFileUploader }
let(:model_class) { Snippet }
before do
create_list(:snippet, 10) do |model|
uploader_class.new(model)
.store!(fixture_file_upload('spec/fixtures/doc_sample.txt'))
end
end
2020-04-08 14:13:33 +05:30
it_behaves_like 'enqueue upload migration jobs in batch', batch: 4
2018-05-09 12:01:36 +05:30
end
2020-05-24 23:13:21 +05:30
context 'for DesignManagement::DesignV432x230Uploader' do
let(:uploader_class) { DesignManagement::DesignV432x230Uploader }
let(:model_class) { DesignManagement::Action }
let(:mounted_as) { :image_v432x230 }
before do
create_list(:design_action, 10, :with_image_v432x230)
end
it_behaves_like 'enqueue upload migration jobs in batch', batch: 4
end
2018-05-09 12:01:36 +05:30
end