BigW Consortium Gitlab

Update tests for new implementation

parent dfd9185d
require 'spec_helper'
feature 'Browse artifact', :js do
include ArtifactHelper
let(:project) { create(:project, :public) }
let(:pipeline) { create(:ci_empty_pipeline, project: project) }
let(:job) { create(:ci_build, :artifacts, pipeline: pipeline) }
......@@ -24,8 +22,8 @@ feature 'Browse artifact', :js do
end
end
context 'when browsing a directory with an HTML file' do
let(:html_entry) { job.artifacts_metadata_entry("other_artifacts_0.1.2/index.html") }
context 'when browsing a directory with an text file' do
let(:txt_entry) { job.artifacts_metadata_entry('other_artifacts_0.1.2/doc_sample.txt') }
before do
allow(Gitlab.config.pages).to receive(:enabled).and_return(true)
......@@ -37,8 +35,7 @@ feature 'Browse artifact', :js do
it "shows external link icon and styles" do
link = first('.tree-item-file-external-link')
expect(link).to have_content('index.html')
expect(link[:href]).to eq(html_artifact_url(project, job, html_entry.blob))
expect(link).to have_content('doc_sample.txt')
expect(page).to have_selector('.js-artifact-tree-external-icon')
end
end
......
require 'spec_helper'
describe ArtifactHelper do
set(:job) { create(:ci_build, :artifacts) }
let(:html_entry) { job.artifacts_metadata_entry("other_artifacts_0.1.2/index.html") }
let(:txt_entry) { job.artifacts_metadata_entry("other_artifacts_0.1.2/doc_sample.txt") }
before do
allow(Gitlab.config.pages).to receive(:enabled).and_return(true)
allow(Gitlab.config.pages).to receive(:artifacts_server).and_return(true)
end
describe '#link_to_artifact' do
context 'link_to_pages returns true' do
subject { link_to_artifact(job.project, job, entry) }
before do
allow(Gitlab.config.pages).to receive(:enabled).and_return(true)
end
context 'when the entry is HTML' do
let(:entry) { html_entry }
it { is_expected.to match Gitlab.config.pages.host }
it { is_expected.to match /-\/jobs\/\d+\/artifacts/ }
end
context 'when the entry is not HTML' do
let(:entry) { txt_entry }
it { is_expected.not_to match Gitlab.config.pages.host }
end
end
end
describe '#external_url?' do
context 'pages enabled' do
before do
allow(Gitlab.config.pages).to receive(:artifacts_server).and_return(true)
end
it 'returns true for HTML files' do
expect(external_url?(txt_entry.blob)).to be(false)
end
it 'returns true for HTML files' do
expect(external_url?(html_entry.blob)).to be(true)
end
end
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment