diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-15 00:07:52 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-15 00:07:52 +0300 |
commit | 67cd2904c9ebd7ba346cc92a37ac953747a3f0e5 (patch) | |
tree | ed10a6a07c43aa4167a40c39409f8e1fef1a4cce /spec/migrations | |
parent | 30b17460a2569734cf04dae1b2841d3654b2c0ec (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/migrations')
4 files changed, 131 insertions, 3 deletions
diff --git a/spec/migrations/cleanup_optimistic_locking_nulls_pt2_fixed_spec.rb b/spec/migrations/cleanup_optimistic_locking_nulls_pt2_fixed_spec.rb index 2f8237c1c1c..2e5e450afc7 100644 --- a/spec/migrations/cleanup_optimistic_locking_nulls_pt2_fixed_spec.rb +++ b/spec/migrations/cleanup_optimistic_locking_nulls_pt2_fixed_spec.rb @@ -4,11 +4,11 @@ require 'spec_helper' require Rails.root.join('db', 'post_migrate', '20200427064130_cleanup_optimistic_locking_nulls_pt2_fixed.rb') describe CleanupOptimisticLockingNullsPt2Fixed, :migration do - TABLES = %w(ci_stages ci_builds ci_pipelines).freeze - TABLES.each do |table| + test_tables = %w(ci_stages ci_builds ci_pipelines).freeze + test_tables.each do |table| let(table.to_sym) { table(table.to_sym) } end - let(:tables) { TABLES.map { |t| method(t.to_sym).call } } + let(:tables) { test_tables.map { |t| method(t.to_sym).call } } before do # Create necessary rows diff --git a/spec/migrations/fill_file_store_ci_job_artifacts_spec.rb b/spec/migrations/fill_file_store_ci_job_artifacts_spec.rb new file mode 100644 index 00000000000..5435a438824 --- /dev/null +++ b/spec/migrations/fill_file_store_ci_job_artifacts_spec.rb @@ -0,0 +1,44 @@ +# frozen_string_literal: true + +require 'spec_helper' +require Rails.root.join('db', 'migrate', '20200513235532_fill_file_store_ci_job_artifacts.rb') + +describe FillFileStoreCiJobArtifacts do + let(:namespaces) { table(:namespaces) } + let(:projects) { table(:projects) } + let(:builds) { table(:ci_builds) } + let(:job_artifacts) { table(:ci_job_artifacts) } + + before do + namespaces.create!(id: 123, name: 'sample', path: 'sample') + projects.create!(id: 123, name: 'sample', path: 'sample', namespace_id: 123) + builds.create!(id: 1) + end + + context 'when file_store is nil' do + it 'updates file_store to local' do + job_artifacts.create!(project_id: 123, job_id: 1, file_type: 1, file_store: nil) + job_artifact = job_artifacts.find_by(project_id: 123, job_id: 1) + + expect { migrate! }.to change { job_artifact.reload.file_store }.from(nil).to(1) + end + end + + context 'when file_store is set to local' do + it 'does not update file_store' do + job_artifacts.create!(project_id: 123, job_id: 1, file_type: 1, file_store: 1) + job_artifact = job_artifacts.find_by(project_id: 123, job_id: 1) + + expect { migrate! }.not_to change { job_artifact.reload.file_store } + end + end + + context 'when file_store is set to object storage' do + it 'does not update file_store' do + job_artifacts.create!(project_id: 123, job_id: 1, file_type: 1, file_store: 2) + job_artifact = job_artifacts.find_by(project_id: 123, job_id: 1) + + expect { migrate! }.not_to change { job_artifact.reload.file_store } + end + end +end diff --git a/spec/migrations/fill_file_store_lfs_objects_spec.rb b/spec/migrations/fill_file_store_lfs_objects_spec.rb new file mode 100644 index 00000000000..e574eacca35 --- /dev/null +++ b/spec/migrations/fill_file_store_lfs_objects_spec.rb @@ -0,0 +1,36 @@ +# frozen_string_literal: true + +require 'spec_helper' +require Rails.root.join('db', 'migrate', '20200513234502_fill_file_store_lfs_objects.rb') + +describe FillFileStoreLfsObjects do + let(:lfs_objects) { table(:lfs_objects) } + let(:oid) { 'b804383982bb89b00e828e3f44c038cc991d3d1768009fc39ba8e2c081b9fb75' } + + context 'when file_store is nil' do + it 'updates file_store to local' do + lfs_objects.create(oid: oid, size: 1062, file_store: nil) + lfs_object = lfs_objects.find_by(oid: oid) + + expect { migrate! }.to change { lfs_object.reload.file_store }.from(nil).to(1) + end + end + + context 'when file_store is set to local' do + it 'does not update file_store' do + lfs_objects.create(oid: oid, size: 1062, file_store: 1) + lfs_object = lfs_objects.find_by(oid: oid) + + expect { migrate! }.not_to change { lfs_object.reload.file_store } + end + end + + context 'when file_store is set to object storage' do + it 'does not update file_store' do + lfs_objects.create(oid: oid, size: 1062, file_store: 2) + lfs_object = lfs_objects.find_by(oid: oid) + + expect { migrate! }.not_to change { lfs_object.reload.file_store } + end + end +end diff --git a/spec/migrations/fill_store_uploads_spec.rb b/spec/migrations/fill_store_uploads_spec.rb new file mode 100644 index 00000000000..6a2a3c4ea8e --- /dev/null +++ b/spec/migrations/fill_store_uploads_spec.rb @@ -0,0 +1,48 @@ +# frozen_string_literal: true + +require 'spec_helper' +require Rails.root.join('db', 'migrate', '20200513235347_fill_store_uploads.rb') + +describe FillStoreUploads do + let(:uploads) { table(:uploads) } + let(:path) { 'uploads/-/system/avatar.jpg' } + + context 'when store is nil' do + it 'updates store to local' do + uploads.create(size: 100.kilobytes, + uploader: 'AvatarUploader', + path: path, + store: nil) + + upload = uploads.find_by(path: path) + + expect { migrate! }.to change { upload.reload.store }.from(nil).to(1) + end + end + + context 'when store is set to local' do + it 'does not update store' do + uploads.create(size: 100.kilobytes, + uploader: 'AvatarUploader', + path: path, + store: 1) + + upload = uploads.find_by(path: path) + + expect { migrate! }.not_to change { upload.reload.store } + end + end + + context 'when store is set to object storage' do + it 'does not update store' do + uploads.create(size: 100.kilobytes, + uploader: 'AvatarUploader', + path: path, + store: 2) + + upload = uploads.find_by(path: path) + + expect { migrate! }.not_to change { upload.reload.store } + end + end +end |