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

local_spec.rb « uploads « models « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 3468399f3704219e6019eae1d191db9e2abcb834 (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
# frozen_string_literal: true

require 'spec_helper'

describe Uploads::Local do
  let(:data_store) { described_class.new }

  before do
    stub_uploads_object_storage(FileUploader)
  end

  context 'model with uploads' do
    let(:project) { create(:project) }
    let(:relation) { project.uploads }

    describe '#keys' do
      let!(:uploads) { create_list(:upload, 2, uploader: FileUploader, model: project) }
      subject { data_store.keys(relation) }

      it 'returns keys' do
        is_expected.to match_array(relation.map(&:absolute_path))
      end
    end

    describe '#delete_keys' do
      let(:keys) { data_store.keys(relation) }
      let!(:uploads) { create_list(:upload, 2, :with_file, :issuable_upload, model: project) }
      subject { data_store.delete_keys(keys) }

      it 'deletes multiple data' do
        paths = relation.map(&:absolute_path)

        paths.each do |path|
          expect(File.exist?(path)).to be_truthy
        end

        subject

        paths.each do |path|
          expect(File.exist?(path)).to be_falsey
        end
      end
    end
  end
end