diff options
author | Markus Koller <mkoller@gitlab.com> | 2019-06-07 13:26:26 +0200 |
---|---|---|
committer | Markus Koller <mkoller@gitlab.com> | 2019-06-07 13:31:26 +0200 |
commit | 8f537845ed513639518bd44fbb0a61426aec2481 (patch) | |
tree | 1d58d4649d66c91c0643629c1d9226d6e5f1f61f /spec | |
parent | 3ef0c54966ec79de0a713e089b62b46c79e8a663 (diff) | |
download | gitlab-ce-8f537845ed513639518bd44fbb0a61426aec2481.tar.gz |
Fix migration specs using factories
We need to stub default_git_depth and default_git_depth= because some
old migrations specs try to create a record using schema before that
column was introduced.
The `let!` calls were executed before the `before` hook which still
caused some factories to fail, so they're created in the `before` hook
now as well.
Diffstat (limited to 'spec')
-rw-r--r-- | spec/lib/gitlab/background_migration/migrate_legacy_uploads_spec.rb | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/spec/lib/gitlab/background_migration/migrate_legacy_uploads_spec.rb b/spec/lib/gitlab/background_migration/migrate_legacy_uploads_spec.rb index 802c8fb8c97..16b9de6a84e 100644 --- a/spec/lib/gitlab/background_migration/migrate_legacy_uploads_spec.rb +++ b/spec/lib/gitlab/background_migration/migrate_legacy_uploads_spec.rb @@ -5,23 +5,39 @@ describe Gitlab::BackgroundMigration::MigrateLegacyUploads, :migration, schema: let(:test_dir) { FileUploader.options['storage_path'] } # rubocop: disable RSpec/FactoriesInMigrationSpecs - let!(:namespace) { create(:namespace) } - let!(:project) { create(:project, :legacy_storage, namespace: namespace) } - let!(:issue) { create(:issue, project: project) } + let(:namespace) { create(:namespace) } + let(:project) { create(:project, :legacy_storage, namespace: namespace) } + let(:issue) { create(:issue, project: project) } - let!(:note1) { create(:note, note: 'some note text awesome', project: project, noteable: issue) } - let!(:note2) { create(:note, note: 'some note', project: project, noteable: issue) } + let(:note1) { create(:note, note: 'some note text awesome', project: project, noteable: issue) } + let(:note2) { create(:note, note: 'some note', project: project, noteable: issue) } - let!(:hashed_project) { create(:project, namespace: namespace) } - let!(:issue_hashed_project) { create(:issue, project: hashed_project) } - let!(:note_hashed_project) { create(:note, note: 'some note', project: hashed_project, attachment: 'text.pdf', noteable: issue_hashed_project) } + let(:hashed_project) { create(:project, namespace: namespace) } + let(:issue_hashed_project) { create(:issue, project: hashed_project) } + let(:note_hashed_project) { create(:note, note: 'some note', project: hashed_project, attachment: 'text.pdf', noteable: issue_hashed_project) } - let!(:standard_upload) do + let(:standard_upload) do create(:upload, path: "secretabcde/image.png", model_id: create(:project).id, model_type: 'Project', uploader: 'FileUploader') end + before do + # This migration was created before we introduced ProjectCiCdSetting#default_git_depth + allow_any_instance_of(ProjectCiCdSetting).to receive(:default_git_depth).and_return(nil) + allow_any_instance_of(ProjectCiCdSetting).to receive(:default_git_depth=).and_return(0) + + namespace + project + issue + note1 + note2 + hashed_project + issue_hashed_project + note_hashed_project + standard_upload + end + def create_remote_upload(model, filename) create(:upload, :attachment_upload, path: "note/attachment/#{model.id}/#{filename}", secret: nil, |