diff options
author | Zeger-Jan van de Weg <git@zjvandeweg.nl> | 2017-10-03 12:34:24 +0200 |
---|---|---|
committer | Zeger-Jan van de Weg <git@zjvandeweg.nl> | 2017-10-03 12:34:24 +0200 |
commit | 8cbfe3aea64a11f8de0e28e35fc1fc298128158e (patch) | |
tree | a12867e59b7ae7584f3a67a406f832bd7cab7ee8 /spec/models/ci | |
parent | ca0e39048f0e92bd615c45bfe555800910396cfd (diff) | |
download | gitlab-ce-8cbfe3aea64a11f8de0e28e35fc1fc298128158e.tar.gz |
Redirect to pages daemon
Diffstat (limited to 'spec/models/ci')
-rw-r--r-- | spec/models/ci/artifact_blob_spec.rb | 43 |
1 files changed, 42 insertions, 1 deletions
diff --git a/spec/models/ci/artifact_blob_spec.rb b/spec/models/ci/artifact_blob_spec.rb index a10a8af5303..3ea11a3bd54 100644 --- a/spec/models/ci/artifact_blob_spec.rb +++ b/spec/models/ci/artifact_blob_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe Ci::ArtifactBlob do - let(:build) { create(:ci_build, :artifacts) } + set(:build) { create(:ci_build, :artifacts) } let(:entry) { build.artifacts_metadata_entry('other_artifacts_0.1.2/another-subdirectory/banana_sample.gif') } subject { described_class.new(entry) } @@ -41,4 +41,45 @@ describe Ci::ArtifactBlob do expect(subject.external_storage).to eq(:build_artifact) end end + + describe '#url' do + before do + allow(Gitlab.config.pages).to receive(:enabled).and_return(true) + allow(Gitlab.config.pages).to receive(:artifacts_server).and_return(true) + end + + context '.gif extension' do + it 'returns nil' do + expect(subject.external_url(build.project, build)).to be_nil + end + end + + context 'txt extensions' do + let(:entry) { build.artifacts_metadata_entry('other_artifacts_0.1.2/doc_sample.txt') } + + it 'returns a URL' do + url = subject.external_url(build.project, build) + + expect(url).not_to be_nil + expect(url).to start_with("http") + expect(url).to match Gitlab.config.pages.host + expect(url).to end_with(entry.path) + end + end + end + + describe '#external_link?' do + before do + allow(Gitlab.config.pages).to receive(:enabled).and_return(true) + allow(Gitlab.config.pages).to receive(:artifacts_server).and_return(true) + end + + it { is_expected.not_to be_external_link } + + context 'txt extensions' do + let(:entry) { build.artifacts_metadata_entry('other_artifacts_0.1.2/doc_sample.txt') } + + it { is_expected.to be_external_link } + end + end end |