2019-07-25 01:24:42 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-05-02 18:42:37 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2018-07-05 02:32:05 -04:00
|
|
|
describe 'Artifact file', :js do
|
2017-08-02 15:55:11 -04:00
|
|
|
let(:project) { create(:project, :public) }
|
2017-07-24 18:51:14 -04:00
|
|
|
let(:pipeline) { create(:ci_empty_pipeline, project: project) }
|
2017-05-02 18:42:37 -04:00
|
|
|
let(:build) { create(:ci_build, :artifacts, pipeline: pipeline) }
|
|
|
|
|
|
|
|
def visit_file(path)
|
2017-05-18 12:57:37 -04:00
|
|
|
visit file_path(path)
|
|
|
|
end
|
|
|
|
|
|
|
|
def file_path(path)
|
2017-06-29 13:06:35 -04:00
|
|
|
file_project_job_artifacts_path(project, build, path)
|
2017-05-02 18:42:37 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'Text file' do
|
|
|
|
before do
|
|
|
|
visit_file('other_artifacts_0.1.2/doc_sample.txt')
|
|
|
|
|
2017-05-17 14:25:13 -04:00
|
|
|
wait_for_requests
|
2017-05-02 18:42:37 -04:00
|
|
|
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-05-17 14:25:13 -04:00
|
|
|
wait_for_requests
|
2017-05-02 18:42:37 -04:00
|
|
|
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-05-18 12:57:37 -04:00
|
|
|
|
|
|
|
context 'when visiting old URL' do
|
|
|
|
let(:file_url) do
|
|
|
|
file_path('other_artifacts_0.1.2/doc_sample.txt')
|
|
|
|
end
|
|
|
|
|
|
|
|
before do
|
2017-05-26 09:55:29 -04:00
|
|
|
visit file_url.sub('/-/jobs', '/builds')
|
2017-05-18 12:57:37 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it "redirects to new URL" do
|
|
|
|
expect(page.current_path).to eq(file_url)
|
|
|
|
end
|
|
|
|
end
|
2017-05-02 18:42:37 -04:00
|
|
|
end
|