2019-07-25 01:24:42 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-05-07 19:39:37 -04:00
|
|
|
require "spec_helper"
|
|
|
|
|
2020-06-16 14:09:01 -04:00
|
|
|
RSpec.describe "User downloads artifacts" do
|
2020-02-26 13:09:24 -05:00
|
|
|
let_it_be(:project) { create(:project, :repository, :public) }
|
|
|
|
let_it_be(:pipeline) { create(:ci_empty_pipeline, status: :success, sha: project.commit.id, project: project) }
|
|
|
|
let_it_be(:job) { create(:ci_build, :artifacts, :success, pipeline: pipeline) }
|
2018-05-07 19:39:37 -04:00
|
|
|
|
|
|
|
shared_examples "downloading" do
|
|
|
|
it "downloads the zip" do
|
2020-01-29 13:08:47 -05:00
|
|
|
expect(page.response_headers['Content-Disposition']).to eq(%Q{attachment; filename="#{job.artifacts_file.filename}"; filename*=UTF-8''#{job.artifacts_file.filename}})
|
2018-05-07 19:39:37 -04:00
|
|
|
expect(page.response_headers['Content-Transfer-Encoding']).to eq("binary")
|
|
|
|
expect(page.response_headers['Content-Type']).to eq("application/zip")
|
|
|
|
expect(page.source.b).to eq(job.artifacts_file.file.read.b)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when downloading" do
|
|
|
|
before do
|
|
|
|
visit(url)
|
|
|
|
end
|
|
|
|
|
|
|
|
context "via job id" do
|
2018-09-25 04:07:47 -04:00
|
|
|
let(:url) { download_project_job_artifacts_path(project, job) }
|
2018-05-07 19:39:37 -04:00
|
|
|
|
|
|
|
it_behaves_like "downloading"
|
|
|
|
end
|
|
|
|
|
|
|
|
context "via branch name and job name" do
|
2018-09-25 04:07:47 -04:00
|
|
|
let(:url) { latest_succeeded_project_artifacts_path(project, "#{pipeline.ref}/download", job: job.name) }
|
2018-05-07 19:39:37 -04:00
|
|
|
|
|
|
|
it_behaves_like "downloading"
|
|
|
|
end
|
2020-05-22 05:08:09 -04:00
|
|
|
|
|
|
|
context "via SHA" do
|
|
|
|
let(:url) { latest_succeeded_project_artifacts_path(project, "#{pipeline.sha}/download", job: job.name) }
|
|
|
|
|
|
|
|
it_behaves_like "downloading"
|
|
|
|
end
|
2018-05-07 19:39:37 -04:00
|
|
|
end
|
|
|
|
end
|