Welcome to mirror list, hosted at ThFree Co, Russian Federation.

fill_store_uploads_spec.rb « migrations « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 19db7c2b48dbd55bfdf7bdc0efbf29ed70bfd577 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# frozen_string_literal: true

require 'spec_helper'
require_migration!

RSpec.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