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.
This commit is contained in:
Grzegorz Bizon 2015-12-28 12:06:27 +01:00
parent 8eeed761a9
commit 5ff7ec42dc
3 changed files with 31 additions and 1 deletions

View File

@ -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

View File

@ -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

View File

@ -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 }