diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2015-12-28 14:06:27 +0300 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-01-14 14:48:14 +0300 |
commit | 5ff7ec42dc8759717c485478261128d61ea70b9a (patch) | |
tree | 68a30bc4a0b967de057d0f5e7160cce3d38b1e90 | |
parent | 8eeed761a9c25ea8ccfc347fbd3f5894b5957d9e (diff) |
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.
-rw-r--r-- | app/models/ci/build.rb | 6 | ||||
-rw-r--r-- | app/views/projects/builds/show.html.haml | 3 | ||||
-rw-r--r-- | spec/models/build_spec.rb | 23 |
3 files changed, 31 insertions, 1 deletions
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb index 327114e0350..1506e957b3c 100644 --- a/app/models/ci/build.rb +++ b/app/models/ci/build.rb @@ -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 diff --git a/app/views/projects/builds/show.html.haml b/app/views/projects/builds/show.html.haml index c7fd047949e..7d32711e642 100644 --- a/app/views/projects/builds/show.html.haml +++ b/app/views/projects/builds/show.html.haml @@ -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 diff --git a/spec/models/build_spec.rb b/spec/models/build_spec.rb index 33e0eb7d5d7..108d7d5ff01 100644 --- a/spec/models/build_spec.rb +++ b/spec/models/build_spec.rb @@ -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 } |