Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/models/ci/artifact_blob_spec.rb')
-rw-r--r--spec/models/ci/artifact_blob_spec.rb72
1 files changed, 30 insertions, 42 deletions
diff --git a/spec/models/ci/artifact_blob_spec.rb b/spec/models/ci/artifact_blob_spec.rb
index c00f46683b9..2e0b13c35ea 100644
--- a/spec/models/ci/artifact_blob_spec.rb
+++ b/spec/models/ci/artifact_blob_spec.rb
@@ -2,105 +2,93 @@
require 'spec_helper'
-RSpec.describe Ci::ArtifactBlob do
- let_it_be(:project) { create(:project, :public) }
+RSpec.describe Ci::ArtifactBlob, feature_category: :continuous_integration do
+ let_it_be(:project) { create(:project, :public, path: 'project1') }
let_it_be(:build) { create(:ci_build, :artifacts, project: project) }
+ let(:pages_port) { nil }
let(:entry) { build.artifacts_metadata_entry('other_artifacts_0.1.2/another-subdirectory/banana_sample.gif') }
- subject { described_class.new(entry) }
+ subject(:blob) { described_class.new(entry) }
+
+ before do
+ stub_pages_setting(
+ enabled: true,
+ artifacts_server: true,
+ access_control: true,
+ port: pages_port
+ )
+ end
describe '#id' do
it 'returns a hash of the path' do
- expect(subject.id).to eq(Digest::SHA1.hexdigest(entry.path))
+ expect(blob.id).to eq(Digest::SHA1.hexdigest(entry.path))
end
end
describe '#name' do
it 'returns the entry name' do
- expect(subject.name).to eq(entry.name)
+ expect(blob.name).to eq(entry.name)
end
end
describe '#path' do
it 'returns the entry path' do
- expect(subject.path).to eq(entry.path)
+ expect(blob.path).to eq(entry.path)
end
end
describe '#size' do
it 'returns the entry size' do
- expect(subject.size).to eq(entry.metadata[:size])
+ expect(blob.size).to eq(entry.metadata[:size])
end
end
describe '#mode' do
it 'returns the entry mode' do
- expect(subject.mode).to eq(entry.metadata[:mode])
+ expect(blob.mode).to eq(entry.metadata[:mode])
end
end
describe '#external_storage' do
it 'returns :build_artifact' do
- expect(subject.external_storage).to eq(:build_artifact)
+ expect(blob.external_storage).to eq(:build_artifact)
end
end
describe '#external_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
+ subject(:url) { blob.external_url(build) }
- describe '.gif extension' do
- it 'returns nil' do
- expect(subject.external_url(build.project, build)).to be_nil
- end
+ context 'with not allowed extension' do
+ it { is_expected.to be_nil }
end
- context 'txt extensions' do
+ context 'with allowed extension' do
let(:path) { 'other_artifacts_0.1.2/doc_sample.txt' }
let(:entry) { build.artifacts_metadata_entry(path) }
- it 'returns a URL' do
- url = subject.external_url(build.project, build)
-
- expect(url).not_to be_nil
- expect(url).to eq("http://#{project.namespace.path}.#{Gitlab.config.pages.host}/-/#{project.path}/-/jobs/#{build.id}/artifacts/#{path}")
- end
+ it { is_expected.to eq("http://#{project.namespace.path}.example.com/-/project1/-/jobs/#{build.id}/artifacts/other_artifacts_0.1.2/doc_sample.txt") }
context 'when port is configured' do
- let(:port) { 1234 }
-
- it 'returns an URL with port number' do
- allow(Gitlab.config.pages).to receive(:url).and_return("#{Gitlab.config.pages.url}:#{port}")
-
- url = subject.external_url(build.project, build)
+ let(:pages_port) { 1234 }
- expect(url).not_to be_nil
- expect(url).to eq("http://#{project.namespace.path}.#{Gitlab.config.pages.host}:#{port}/-/#{project.path}/-/jobs/#{build.id}/artifacts/#{path}")
- end
+ it { is_expected.to eq("http://#{project.namespace.path}.example.com:1234/-/project1/-/jobs/#{build.id}/artifacts/other_artifacts_0.1.2/doc_sample.txt") }
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
-
- context 'gif extensions' do
+ context 'with not allowed extensions' do
it 'returns false' do
- expect(subject.external_link?(build)).to be false
+ expect(blob.external_link?(build)).to be false
end
end
- context 'txt extensions' do
+ context 'with allowed extensions' do
let(:entry) { build.artifacts_metadata_entry('other_artifacts_0.1.2/doc_sample.txt') }
it 'returns true' do
- expect(subject.external_link?(build)).to be true
+ expect(blob.external_link?(build)).to be true
end
end
end