diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-11-17 00:29:57 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-11-17 00:29:57 +0300 |
commit | 899da2d359848b005984373052b2e697fd5d10f2 (patch) | |
tree | b4b93613f08ed28f8c954b2517742e8d71029ed7 /spec | |
parent | 6d558d71eba0e5c8025e2a093ce8d144b1fdd4cf (diff) |
Add latest changes from gitlab-org/gitlab@16-6-stable-ee
Diffstat (limited to 'spec')
-rw-r--r-- | spec/models/pages_deployment_spec.rb | 10 | ||||
-rw-r--r-- | spec/uploaders/pages/deployment_uploader_spec.rb | 39 |
2 files changed, 31 insertions, 18 deletions
diff --git a/spec/models/pages_deployment_spec.rb b/spec/models/pages_deployment_spec.rb index 1e6f8b33a86..fdd320f13ad 100644 --- a/spec/models/pages_deployment_spec.rb +++ b/spec/models/pages_deployment_spec.rb @@ -71,6 +71,16 @@ RSpec.describe PagesDeployment, feature_category: :pages do end end + describe '#upload_ready' do + it 'marks #upload_ready as true when upload finishes' do + deployment = build(:pages_deployment) + + expect { deployment.save! } + .to change { deployment.upload_ready } + .from(false).to(true) + end + end + describe '.deactivate_all', :freeze_time do let!(:deployment) { create(:pages_deployment, project: project, updated_at: 5.minutes.ago) } let!(:nil_path_prefix_deployment) { create(:pages_deployment, project: project, path_prefix: nil) } diff --git a/spec/uploaders/pages/deployment_uploader_spec.rb b/spec/uploaders/pages/deployment_uploader_spec.rb index a5fe2dfe9ba..efca5bd0cf1 100644 --- a/spec/uploaders/pages/deployment_uploader_spec.rb +++ b/spec/uploaders/pages/deployment_uploader_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Pages::DeploymentUploader do +RSpec.describe Pages::DeploymentUploader, feature_category: :pages do let(:pages_deployment) { create(:pages_deployment) } let(:uploader) { described_class.new(pages_deployment, :file) } @@ -22,38 +22,41 @@ RSpec.describe Pages::DeploymentUploader 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] + describe '.default_store' do + it 'returns remote store when object storage is enabled' do + expect(described_class.default_store).to eq(ObjectStorage::Store::REMOTE) + end + end it 'preserves original file when stores it' do uploader.store!(file) expect(File.exist?(file.path)).to be true end + + it_behaves_like 'builds correct paths', + store_dir: %r[\A\h{2}/\h{2}/\h{64}/pages_deployments/\d+\z] end context 'when file is stored in valid local_path' do - before do - uploader.store!(file) + 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 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 + it 'builds the right file path' do + uploader.store!(file) - 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) + expect(uploader.file.path).to match( + %r[#{uploader.root}/@hashed/\h{2}/\h{2}/\h{64}/pages_deployments/#{pages_deployment.id}/pages.zip] + ) end - it 'returns remote store when object storage is enabled' do - stub_pages_object_storage + it 'preserves original file when stores it' do + uploader.store!(file) - expect(described_class.default_store).to eq(ObjectStorage::Store::REMOTE) + expect(File.exist?(file.path)).to be true end end end |