diff options
author | Thong Kuah <tkuah@gitlab.com> | 2019-09-12 01:35:10 +0300 |
---|---|---|
committer | Thong Kuah <tkuah@gitlab.com> | 2019-09-12 01:35:10 +0300 |
commit | eef1a7fe2c0964e0b507e3d7e557fc437570454c (patch) | |
tree | 6a1e5fdfb8014e68d75d6fca2a612d0824deff96 /spec/support | |
parent | 6c89bc7eae70ad9a63c4014d6457a80c18412fe5 (diff) | |
parent | 3c2b4a1cede956d5160ccf08d0a561bf31248161 (diff) |
Merge branch 'static-objects-external-storage' into 'master'
Enable serving static objects from an external storage
See merge request gitlab-org/gitlab-ce!31025
Diffstat (limited to 'spec/support')
-rw-r--r-- | spec/support/shared_examples/features/archive_download_buttons_shared_examples.rb | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/spec/support/shared_examples/features/archive_download_buttons_shared_examples.rb b/spec/support/shared_examples/features/archive_download_buttons_shared_examples.rb new file mode 100644 index 00000000000..920fcbde483 --- /dev/null +++ b/spec/support/shared_examples/features/archive_download_buttons_shared_examples.rb @@ -0,0 +1,59 @@ +# frozen_string_literal: true + +shared_examples 'archive download buttons' do + let(:formats) { %w(zip tar.gz tar.bz2 tar) } + let(:path_to_visit) { project_path(project) } + let(:ref) { project.default_branch } + + context 'when static objects external storage is enabled' do + before do + allow_any_instance_of(ApplicationSetting).to receive(:static_objects_external_storage_url).and_return('https://cdn.gitlab.com') + visit path_to_visit + end + + context 'private project' do + it 'shows archive download buttons with external storage URL prepended and user token appended to their href' do + formats.each do |format| + path = archive_path(project, ref, format) + uri = URI('https://cdn.gitlab.com') + uri.path = path + uri.query = "token=#{user.static_object_token}" + + expect(page).to have_link format, href: uri.to_s + end + end + end + + context 'public project' do + let(:project) { create(:project, :repository, :public) } + + it 'shows archive download buttons with external storage URL prepended to their href' do + formats.each do |format| + path = archive_path(project, ref, format) + uri = URI('https://cdn.gitlab.com') + uri.path = path + + expect(page).to have_link format, href: uri.to_s + end + end + end + end + + context 'when static objects external storage is disabled' do + before do + visit path_to_visit + end + + it 'shows default archive download buttons' do + formats.each do |format| + path = archive_path(project, ref, format) + + expect(page).to have_link format, href: path + end + end + end + + def archive_path(project, ref, format) + project_archive_path(project, id: "#{ref}/#{project.path}-#{ref}", path: nil, format: format) + end +end |