debian-mirror-gitlab/spec/features/projects/artifacts/file_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

80 lines
2 KiB
Ruby
Raw Normal View History

2019-10-12 21:52:04 +05:30
# frozen_string_literal: true
2017-08-17 22:00:37 +05:30
require 'spec_helper'
2020-06-23 00:09:42 +05:30
RSpec.describe 'Artifact file', :js do
2017-08-17 22:00:37 +05:30
let(:project) { create(:project, :public) }
2017-09-10 17:25:29 +05:30
let(:pipeline) { create(:ci_empty_pipeline, project: project) }
2017-08-17 22:00:37 +05:30
let(:build) { create(:ci_build, :artifacts, pipeline: pipeline) }
def visit_file(path)
2017-09-10 17:25:29 +05:30
visit file_path(path)
end
def file_path(path)
file_project_job_artifacts_path(project, build, path)
2017-08-17 22:00:37 +05:30
end
context 'Text file' do
before do
visit_file('other_artifacts_0.1.2/doc_sample.txt')
2017-09-10 17:25:29 +05:30
wait_for_requests
2017-08-17 22:00:37 +05:30
end
it 'displays an error' do
aggregate_failures do
# shows an error message
expect(page).to have_content('The source could not be displayed because it is stored as a job artifact. You can download it instead.')
# does not show a viewer switcher
expect(page).not_to have_selector('.js-blob-viewer-switcher')
# does not show a copy button
expect(page).not_to have_selector('.js-copy-blob-source-btn')
# shows a download button
expect(page).to have_link('Download')
end
end
end
context 'JPG file' do
before do
visit_file('rails_sample.jpg')
2017-09-10 17:25:29 +05:30
wait_for_requests
2017-08-17 22:00:37 +05:30
end
it 'displays the blob' do
aggregate_failures do
# shows rendered image
expect(page).to have_selector('.image_file img')
# does not show a viewer switcher
expect(page).not_to have_selector('.js-blob-viewer-switcher')
# does not show a copy button
expect(page).not_to have_selector('.js-copy-blob-source-btn')
# shows a download button
expect(page).to have_link('Download')
end
end
end
2017-09-10 17:25:29 +05:30
context 'when visiting old URL' do
let(:file_url) do
file_path('other_artifacts_0.1.2/doc_sample.txt')
end
before do
visit file_url.sub('/-/jobs', '/builds')
end
it "redirects to new URL" do
2022-05-07 20:08:51 +05:30
expect(page).to have_current_path(file_url, ignore_query: true)
2017-09-10 17:25:29 +05:30
end
end
2017-08-17 22:00:37 +05:30
end