diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-09-19 04:45:44 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-09-19 04:45:44 +0300 |
commit | 85dc423f7090da0a52c73eb66faf22ddb20efff9 (patch) | |
tree | 9160f299afd8c80c038f08e1545be119f5e3f1e1 /spec/models/pages/lookup_path_spec.rb | |
parent | 15c2c8c66dbe422588e5411eee7e68f1fa440bb8 (diff) |
Add latest changes from gitlab-org/gitlab@13-4-stable-ee
Diffstat (limited to 'spec/models/pages/lookup_path_spec.rb')
-rw-r--r-- | spec/models/pages/lookup_path_spec.rb | 61 |
1 files changed, 49 insertions, 12 deletions
diff --git a/spec/models/pages/lookup_path_spec.rb b/spec/models/pages/lookup_path_spec.rb index 38bd9b39a56..cb1938a0113 100644 --- a/spec/models/pages/lookup_path_spec.rb +++ b/spec/models/pages/lookup_path_spec.rb @@ -3,20 +3,20 @@ require 'spec_helper' RSpec.describe Pages::LookupPath do - let(:project) do - instance_double(Project, - id: 12345, - private_pages?: true, - pages_https_only?: true, - full_path: 'the/full/path' - ) + let_it_be(:project) do + create(:project, :pages_private, pages_https_only: true) end subject(:lookup_path) { described_class.new(project) } + before do + stub_pages_setting(access_control: true, external_https: ["1.1.1.1:443"]) + stub_artifacts_object_storage + end + describe '#project_id' do it 'delegates to Project#id' do - expect(lookup_path.project_id).to eq(12345) + expect(lookup_path.project_id).to eq(project.id) end end @@ -47,12 +47,49 @@ RSpec.describe Pages::LookupPath do end describe '#source' do - it 'sets the source type to "file"' do - expect(lookup_path.source[:type]).to eq('file') + shared_examples 'uses disk storage' do + it 'sets the source type to "file"' do + expect(lookup_path.source[:type]).to eq('file') + end + + it 'sets the source path to the project full path suffixed with "public/' do + expect(lookup_path.source[:path]).to eq(project.full_path + "/public/") + end end - it 'sets the source path to the project full path suffixed with "public/' do - expect(lookup_path.source[:path]).to eq('the/full/path/public/') + include_examples 'uses disk storage' + + context 'when artifact_id from build job is present in pages metadata' do + let(:artifacts_archive) { create(:ci_job_artifact, :zip, :remote_store, project: project) } + + before do + project.mark_pages_as_deployed(artifacts_archive: artifacts_archive) + end + + it 'sets the source type to "zip"' do + expect(lookup_path.source[:type]).to eq('zip') + end + + it 'sets the source path to the artifacts archive URL' do + Timecop.freeze do + expect(lookup_path.source[:path]).to eq(artifacts_archive.file.url(expire_at: 1.day.from_now)) + expect(lookup_path.source[:path]).to include("Expires=86400") + end + end + + context 'when artifact is not uploaded to object storage' do + let(:artifacts_archive) { create(:ci_job_artifact, :zip) } + + include_examples 'uses disk storage' + end + + context 'when feature flag is disabled' do + before do + stub_feature_flags(pages_artifacts_archive: false) + end + + include_examples 'uses disk storage' + end end end |