diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-19 11:27:35 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-19 11:27:35 +0300 |
commit | 7e9c479f7de77702622631cff2628a9c8dcbc627 (patch) | |
tree | c8f718a08e110ad7e1894510980d2155a6549197 /spec/models/pages_deployment_spec.rb | |
parent | e852b0ae16db4052c1c567d9efa4facc81146e88 (diff) |
Add latest changes from gitlab-org/gitlab@13-6-stable-eev13.6.0-rc42
Diffstat (limited to 'spec/models/pages_deployment_spec.rb')
-rw-r--r-- | spec/models/pages_deployment_spec.rb | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/spec/models/pages_deployment_spec.rb b/spec/models/pages_deployment_spec.rb index 5d26ade740e..e83cbc15004 100644 --- a/spec/models/pages_deployment_spec.rb +++ b/spec/models/pages_deployment_spec.rb @@ -10,8 +10,15 @@ RSpec.describe PagesDeployment do describe 'validations' do it { is_expected.to validate_presence_of(:file) } + it { is_expected.to validate_presence_of(:size) } it { is_expected.to validate_numericality_of(:size).only_integer.is_greater_than(0) } + + it { is_expected.to validate_presence_of(:file_count) } + it { is_expected.to validate_numericality_of(:file_count).only_integer.is_greater_than_or_equal_to(0) } + + it { is_expected.to validate_presence_of(:file_sha256) } + it { is_expected.to validate_inclusion_of(:file_store).in_array(ObjectStorage::SUPPORTED_STORES) } it 'is valid when created from the factory' do @@ -20,14 +27,26 @@ RSpec.describe PagesDeployment do end describe 'default for file_store' do + let(:project) { create(:project) } + let(:deployment) do + filepath = Rails.root.join("spec/fixtures/pages.zip") + + described_class.create!( + project: project, + file: fixture_file_upload(filepath), + file_sha256: Digest::SHA256.file(filepath).hexdigest, + file_count: 3 + ) + end + it 'uses local store when object storage is not enabled' do - expect(build(:pages_deployment).file_store).to eq(ObjectStorage::Store::LOCAL) + expect(deployment.file_store).to eq(ObjectStorage::Store::LOCAL) end it 'uses remote store when object storage is enabled' do stub_pages_object_storage(::Pages::DeploymentUploader) - expect(build(:pages_deployment).file_store).to eq(ObjectStorage::Store::REMOTE) + expect(deployment.file_store).to eq(ObjectStorage::Store::REMOTE) end end @@ -35,4 +54,17 @@ RSpec.describe PagesDeployment do deployment = create(:pages_deployment) expect(deployment.size).to eq(deployment.file.size) end + + describe '.older_than' do + it 'returns deployments with lower id' do + old_deployments = create_list(:pages_deployment, 2) + + deployment = create(:pages_deployment) + + # new deployment + create(:pages_deployment) + + expect(PagesDeployment.older_than(deployment.id)).to eq(old_deployments) + end + end end |