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:
parent
8eeed761a9
commit
5ff7ec42dc
|
@ -339,6 +339,12 @@ module Ci
|
||||||
artifacts?
|
artifacts?
|
||||||
end
|
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)
|
def artifacts_metadata(path)
|
||||||
[]
|
[]
|
||||||
end
|
end
|
||||||
|
|
|
@ -96,7 +96,8 @@
|
||||||
.panel-body
|
.panel-body
|
||||||
.btn-group{ role: :group }
|
.btn-group{ role: :group }
|
||||||
= link_to "Download", @build.artifacts_download_url, class: 'btn btn-sm btn-primary'
|
= 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
|
.build-widget
|
||||||
%h4.title
|
%h4.title
|
||||||
|
|
|
@ -391,6 +391,29 @@ describe Ci::Build, models: true do
|
||||||
end
|
end
|
||||||
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
|
describe :repo_url do
|
||||||
let(:build) { FactoryGirl.create :ci_build }
|
let(:build) { FactoryGirl.create :ci_build }
|
||||||
let(:project) { build.project }
|
let(:project) { build.project }
|
||||||
|
|
Loading…
Reference in New Issue