BigW Consortium Gitlab

Commit 5ff7ec42 by Grzegorz Bizon

Add method that checks if artifacts browser is supported

This is needed because of backward compatibility. Previously artifacts archive had `.tar.gz` format, but artifacts browser requires ZIP format now.
parent 8eeed761
......@@ -339,6 +339,12 @@ module Ci
artifacts?
end
def artifacts_browser_supported?
# TODO, since carrierwave 0.10.0 we will be able to check mime type here
#
artifacts? && artifacts_file.path.end_with?('zip')
end
def artifacts_metadata(path)
[]
end
......
......@@ -96,7 +96,8 @@
.panel-body
.btn-group{ role: :group }
= link_to "Download", @build.artifacts_download_url, class: 'btn btn-sm btn-primary'
= link_to "Browse", @build.artifacts_browse_url, class: 'btn btn-sm btn-primary'
- if @build.artifacts_browser_supported?
= link_to "Browse", @build.artifacts_browse_url, class: 'btn btn-sm btn-primary'
.build-widget
%h4.title
......
......@@ -391,6 +391,29 @@ describe Ci::Build, models: true do
end
end
describe :artifacts_browser_supported? do
subject { build.artifacts_browser_supported? }
before do
file = fixture_file_upload(archive_file, archive_type)
build.update_attributes(artifacts_file: file)
end
context 'artifacts archive is not a zip file' do
let(:archive_file) { Rails.root + 'spec/fixtures/banana_sample.gif' }
let(:archive_type) { 'image/gif' }
it { is_expected.to be_falsy }
end
context 'artifacts archive is a zip file' do
let(:archive_file) { Rails.root + 'spec/fixtures/ci_build_artifacts.zip' }
let(:archive_type) { 'application/zip' }
it { is_expected.to be_truthy }
end
end
describe :repo_url do
let(:build) { FactoryGirl.create :ci_build }
let(:project) { build.project }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment