2019-10-12 21:52:04 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-10-15 14:42:47 +05:30
|
|
|
require "spec_helper"
|
|
|
|
|
|
|
|
describe "User downloads artifacts" do
|
2019-10-12 21:52:04 +05:30
|
|
|
set(:project) { create(:project, :repository, :public) }
|
|
|
|
set(:pipeline) { create(:ci_empty_pipeline, status: :success, sha: project.commit.id, project: project) }
|
2018-10-15 14:42:47 +05:30
|
|
|
set(:job) { create(:ci_build, :artifacts, :success, pipeline: pipeline) }
|
|
|
|
|
|
|
|
shared_examples "downloading" do
|
|
|
|
it "downloads the zip" do
|
2020-03-13 15:44:24 +05:30
|
|
|
expect(page.response_headers['Content-Disposition']).to eq(%Q{attachment; filename="#{job.artifacts_file.filename}"; filename*=UTF-8''#{job.artifacts_file.filename}})
|
2018-10-15 14:42:47 +05:30
|
|
|
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-12-05 23:21:45 +05:30
|
|
|
let(:url) { download_project_job_artifacts_path(project, job) }
|
2018-10-15 14:42:47 +05:30
|
|
|
|
|
|
|
it_behaves_like "downloading"
|
|
|
|
end
|
|
|
|
|
|
|
|
context "via branch name and job name" do
|
2018-12-05 23:21:45 +05:30
|
|
|
let(:url) { latest_succeeded_project_artifacts_path(project, "#{pipeline.ref}/download", job: job.name) }
|
2018-10-15 14:42:47 +05:30
|
|
|
|
|
|
|
it_behaves_like "downloading"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|