diff --git a/lib/gitlab/background_migration/populate_untracked_uploads.rb b/lib/gitlab/background_migration/populate_untracked_uploads.rb index 934431ccddd..ef0f1209ef5 100644 --- a/lib/gitlab/background_migration/populate_untracked_uploads.rb +++ b/lib/gitlab/background_migration/populate_untracked_uploads.rb @@ -15,39 +15,39 @@ module Gitlab { pattern: /\A-\/system\/appearance\/logo\/(\d+)/, uploader: 'AttachmentUploader', - model_type: 'Appearance', + model_type: 'Appearance' }, { pattern: /\A-\/system\/appearance\/header_logo\/(\d+)/, uploader: 'AttachmentUploader', - model_type: 'Appearance', + model_type: 'Appearance' }, { pattern: /\A-\/system\/note\/attachment\/(\d+)/, uploader: 'AttachmentUploader', - model_type: 'Note', + model_type: 'Note' }, { pattern: /\A-\/system\/user\/avatar\/(\d+)/, uploader: 'AvatarUploader', - model_type: 'User', + model_type: 'User' }, { pattern: /\A-\/system\/group\/avatar\/(\d+)/, uploader: 'AvatarUploader', - model_type: 'Namespace', + model_type: 'Namespace' }, { pattern: /\A-\/system\/project\/avatar\/(\d+)/, uploader: 'AvatarUploader', - model_type: 'Project', + model_type: 'Project' }, { pattern: FILE_UPLOADER_PATH_PATTERN, uploader: 'FileUploader', model_type: 'Project' - }, - ] + } + ].freeze scope :untracked, -> { where(tracked: false) } diff --git a/lib/gitlab/background_migration/prepare_unhashed_uploads.rb b/lib/gitlab/background_migration/prepare_unhashed_uploads.rb index 556457039fa..7c426022304 100644 --- a/lib/gitlab/background_migration/prepare_unhashed_uploads.rb +++ b/lib/gitlab/background_migration/prepare_unhashed_uploads.rb @@ -5,8 +5,8 @@ module Gitlab include Database::MigrationHelpers FILE_PATH_BATCH_SIZE = 500 - UPLOAD_DIR = "#{CarrierWave.root}/uploads" - FOLLOW_UP_MIGRATION = 'PopulateUntrackedUploads' + UPLOAD_DIR = "#{CarrierWave.root}/uploads".freeze + FOLLOW_UP_MIGRATION = 'PopulateUntrackedUploads'.freeze class UnhashedUploadFile < ActiveRecord::Base include EachBatch @@ -33,7 +33,7 @@ module Gitlab end def store_unhashed_upload_file_paths - return unless Dir.exists?(UPLOAD_DIR) + return unless Dir.exist?(UPLOAD_DIR) file_paths = [] each_file_path(UPLOAD_DIR) do |file_path| diff --git a/spec/lib/gitlab/background_migration/populate_untracked_uploads_spec.rb b/spec/lib/gitlab/background_migration/populate_untracked_uploads_spec.rb index 5446edae06f..82d5a588a56 100644 --- a/spec/lib/gitlab/background_migration/populate_untracked_uploads_spec.rb +++ b/spec/lib/gitlab/background_migration/populate_untracked_uploads_spec.rb @@ -129,7 +129,7 @@ describe Gitlab::BackgroundMigration::PopulateUntrackedUploads::UnhashedUploadFi it 'does not add an upload' do expect do unhashed_upload_file.ensure_tracked! - end.to_not change { upload_class.count }.from(1) + end.not_to change { upload_class.count }.from(1) end end end diff --git a/spec/migrations/track_untracked_uploads_spec.rb b/spec/migrations/track_untracked_uploads_spec.rb index 9539993be31..d896a3e7d54 100644 --- a/spec/migrations/track_untracked_uploads_spec.rb +++ b/spec/migrations/track_untracked_uploads_spec.rb @@ -37,7 +37,7 @@ describe TrackUntrackedUploads, :migration, :sidekiq do migrate! max_length_namespace_path = max_length_project_path = max_length_filename = 'a' * 255 - long_path = "./uploads#{("/#{max_length_namespace_path}") * Namespace::NUMBER_OF_ANCESTORS_ALLOWED}/#{max_length_project_path}/#{max_length_filename}" + long_path = "./uploads#{"/#{max_length_namespace_path}" * Namespace::NUMBER_OF_ANCESTORS_ALLOWED}/#{max_length_project_path}/#{max_length_filename}" unhashed_upload_file = UnhashedUploadFile.new(path: long_path) unhashed_upload_file.save! expect(UnhashedUploadFile.first.path.size).to eq(5641) @@ -106,7 +106,7 @@ describe TrackUntrackedUploads, :migration, :sidekiq do expect(user1.reload.uploads.first.attributes).to include({ "path" => "uploads/-/system/user/avatar/#{user1.id}/rails_sample.jpg", - "uploader" => "AvatarUploader", + "uploader" => "AvatarUploader" }.merge(rails_sample_jpg_attrs)) expect(project1.reload.uploads.first.attributes).to include({ "path" => "uploads/-/system/project/avatar/#{project1.id}/rails_sample.jpg",