summaryrefslogtreecommitdiff
path: root/spec/uploaders
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-10-21 07:08:36 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-10-21 07:08:36 +0000
commit48aff82709769b098321c738f3444b9bdaa694c6 (patch)
treee00c7c43e2d9b603a5a6af576b1685e400410dee /spec/uploaders
parent879f5329ee916a948223f8f43d77fba4da6cd028 (diff)
downloadgitlab-ce-48aff82709769b098321c738f3444b9bdaa694c6.tar.gz
Add latest changes from gitlab-org/gitlab@13-5-stable-eev13.5.0-rc42
Diffstat (limited to 'spec/uploaders')
-rw-r--r--spec/uploaders/file_uploader_spec.rb2
-rw-r--r--spec/uploaders/object_storage_spec.rb2
-rw-r--r--spec/uploaders/pages/deployment_uploader_spec.rb59
-rw-r--r--spec/uploaders/terraform/versioned_state_uploader_spec.rb20
4 files changed, 80 insertions, 3 deletions
diff --git a/spec/uploaders/file_uploader_spec.rb b/spec/uploaders/file_uploader_spec.rb
index 9f1d276d092..1287b809223 100644
--- a/spec/uploaders/file_uploader_spec.rb
+++ b/spec/uploaders/file_uploader_spec.rb
@@ -285,7 +285,7 @@ RSpec.describe FileUploader do
end
let!(:fog_file) do
- fog_connection.directories.new(key: 'uploads').files.create(
+ fog_connection.directories.new(key: 'uploads').files.create( # rubocop:disable Rails/SaveBang
key: 'tmp/uploads/test/123123',
body: 'content'
)
diff --git a/spec/uploaders/object_storage_spec.rb b/spec/uploaders/object_storage_spec.rb
index c73a9a7aab1..ba8d0ccbd02 100644
--- a/spec/uploaders/object_storage_spec.rb
+++ b/spec/uploaders/object_storage_spec.rb
@@ -795,7 +795,7 @@ RSpec.describe ObjectStorage do
end
let!(:fog_file) do
- fog_connection.directories.new(key: 'uploads').files.create(
+ fog_connection.directories.new(key: 'uploads').files.create( # rubocop:disable Rails/SaveBang
key: 'tmp/uploads/test/123123',
body: 'content'
)
diff --git a/spec/uploaders/pages/deployment_uploader_spec.rb b/spec/uploaders/pages/deployment_uploader_spec.rb
new file mode 100644
index 00000000000..1832f73bd67
--- /dev/null
+++ b/spec/uploaders/pages/deployment_uploader_spec.rb
@@ -0,0 +1,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
diff --git a/spec/uploaders/terraform/versioned_state_uploader_spec.rb b/spec/uploaders/terraform/versioned_state_uploader_spec.rb
index ecc3f943480..eeb54cb61c7 100644
--- a/spec/uploaders/terraform/versioned_state_uploader_spec.rb
+++ b/spec/uploaders/terraform/versioned_state_uploader_spec.rb
@@ -12,9 +12,18 @@ RSpec.describe Terraform::VersionedStateUploader do
end
describe '#filename' do
- it 'contains the UUID of the terraform state record' do
+ it 'contains the version of the terraform state record' do
expect(subject.filename).to eq("#{model.version}.tfstate")
end
+
+ context 'legacy state with versioning disabled' do
+ let(:state) { create(:legacy_terraform_state) }
+ let(:model) { create(:terraform_state_version, terraform_state: state) }
+
+ it 'contains the UUID of the terraform state record' do
+ expect(subject.filename).to eq("#{model.uuid}.tfstate")
+ end
+ end
end
describe '#store_dir' do
@@ -25,5 +34,14 @@ RSpec.describe Terraform::VersionedStateUploader do
expect(subject.store_dir).to eq(:store_dir)
end
+
+ context 'legacy state with versioning disabled' do
+ let(:state) { create(:legacy_terraform_state) }
+ let(:model) { create(:terraform_state_version, terraform_state: state) }
+
+ it 'contains the ID of the project' do
+ expect(subject.store_dir).to include(model.project_id.to_s)
+ end
+ end
end
end