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/lib/gitlab/code_navigation_path_spec.rb')
-rw-r--r--spec/lib/gitlab/code_navigation_path_spec.rb31
1 files changed, 21 insertions, 10 deletions
diff --git a/spec/lib/gitlab/code_navigation_path_spec.rb b/spec/lib/gitlab/code_navigation_path_spec.rb
index cafe362c8c7..938a2f821fd 100644
--- a/spec/lib/gitlab/code_navigation_path_spec.rb
+++ b/spec/lib/gitlab/code_navigation_path_spec.rb
@@ -4,18 +4,29 @@ require 'spec_helper'
describe Gitlab::CodeNavigationPath do
context 'when there is an artifact with code navigation data' do
- let(:project) { create(:project, :repository) }
- let(:sha) { project.commit.id }
- let(:build_name) { Gitlab::CodeNavigationPath::CODE_NAVIGATION_JOB_NAME }
+ let_it_be(:project) { create(:project, :repository) }
+ let_it_be(:sha) { project.repository.commits('master', limit: 5).last.id }
+ let_it_be(:pipeline) { create(:ci_pipeline, project: project, sha: sha) }
+ let_it_be(:job) { create(:ci_build, pipeline: pipeline) }
+ let_it_be(:artifact) { create(:ci_job_artifact, :lsif, job: job) }
+
+ let(:commit_sha) { sha }
let(:path) { 'lib/app.rb' }
- let!(:pipeline) { create(:ci_pipeline, project: project, sha: sha) }
- let!(:job) { create(:ci_build, pipeline: pipeline, name: build_name) }
- let!(:artifact) { create(:ci_job_artifact, :lsif, job: job) }
- subject { described_class.new(project, sha).full_json_path_for(path) }
+ subject { described_class.new(project, commit_sha).full_json_path_for(path) }
+
+ context 'when a pipeline exist for a sha' do
+ it 'returns path to a file in the artifact' do
+ expect(subject).to eq("/#{project.full_path}/-/jobs/#{job.id}/artifacts/raw/lsif/#{path}.json?file_type=lsif")
+ end
+ end
+
+ context 'when a pipeline exist for the latest commits' do
+ let(:commit_sha) { project.commit.id }
- it 'assigns code_navigation_build variable' do
- expect(subject).to eq("/#{project.full_path}/-/jobs/#{job.id}/artifacts/raw/lsif/#{path}.json")
+ it 'returns path to a file in the artifact' do
+ expect(subject).to eq("/#{project.full_path}/-/jobs/#{job.id}/artifacts/raw/lsif/#{path}.json?file_type=lsif")
+ end
end
context 'when code_navigation feature is disabled' do
@@ -23,7 +34,7 @@ describe Gitlab::CodeNavigationPath do
stub_feature_flags(code_navigation: false)
end
- it 'does not assign code_navigation_build variable' do
+ it 'returns nil' do
expect(subject).to be_nil
end
end