blob: 7686efd4fe4a1017362bdcfbd7f8ccc670a9382d (
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
49
50
51
52
53
54
55
56
57
58
59
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Pages::DeploymentUploader do
let(:pages_deployment) { create(:pages_deployment) }
let(:uploader) { described_class.new(pages_deployment, :file) }
let(:file) do
fixture_file_upload("spec/fixtures/pages.zip")
end
subject { uploader }
it_behaves_like "builds correct paths",
store_dir: %r[/\h{2}/\h{2}/\h{64}/pages_deployments/\d+],
cache_dir: %r[pages/@hashed/tmp/cache],
work_dir: %r[pages/@hashed/tmp/work]
context 'when object store is REMOTE' do
before do
stub_pages_object_storage
end
it_behaves_like 'builds correct paths', store_dir: %r[\A\h{2}/\h{2}/\h{64}/pages_deployments/\d+\z]
it 'preserves original file when stores it' do
uploader.store!(file)
expect(File.exist?(file.path)).to be true
end
end
context 'when file is stored in valid local_path' do
before do
uploader.store!(file)
end
subject { uploader.file.path }
it { is_expected.to match(%r[#{uploader.root}/@hashed/\h{2}/\h{2}/\h{64}/pages_deployments/#{pages_deployment.id}/pages.zip]) }
it 'preserves original file when stores it' do
expect(File.exist?(file.path)).to be true
end
end
describe '.default_store' do
it 'returns local store when object storage is not enabled' do
expect(described_class.default_store).to eq(ObjectStorage::Store::LOCAL)
end
it 'returns remote store when object storage is enabled' do
stub_pages_object_storage
expect(described_class.default_store).to eq(ObjectStorage::Store::REMOTE)
end
end
end
|