Commit 059cb9eb authored by mfluharty's avatar mfluharty

Move and/or copy related specs

Job artifact: associated_file_types_for
Pipeline: batch_lookup_report_artifact_for_file_type
MR widget entity: blob_path and code quality artifacts
parent 52344221
......@@ -20,17 +20,6 @@ RSpec.describe MergeRequestWidgetEntity do
described_class.new(merge_request, current_user: user, request: request)
end
it 'has blob path data' do
allow(merge_request).to receive_messages(
base_pipeline: pipeline,
head_pipeline: pipeline
)
expect(subject.as_json).to include(:blob_path)
expect(subject.as_json[:blob_path]).to include(:base_path)
expect(subject.as_json[:blob_path]).to include(:head_path)
end
def create_all_artifacts
artifacts = %i(codequality performance browser_performance load_performance)
......
......@@ -308,6 +308,12 @@ FactoryBot.define do
end
end
trait :codequality_report do
after(:build) do |build|
build.job_artifacts << create(:ci_job_artifact, :codequality, job: build)
end
end
trait :test_reports do
after(:build) do |build|
build.job_artifacts << create(:ci_job_artifact, :junit, job: build)
......
......@@ -73,6 +73,14 @@ FactoryBot.define do
end
end
trait :with_codequality_report do
status { :success }
after(:build) do |pipeline, evaluator|
pipeline.builds << build(:ci_build, :codequality_report, pipeline: pipeline, project: pipeline.project)
end
end
trait :with_test_reports do
status { :success }
......
......@@ -110,6 +110,21 @@ RSpec.describe Ci::JobArtifact do
end
end
describe '.associated_file_types_for' do
using RSpec::Parameterized::TableSyntax
subject { Ci::JobArtifact.associated_file_types_for(file_type) }
where(:file_type, :result) do
'codequality' | %w(codequality)
'quality' | nil
end
with_them do
it { is_expected.to eq result }
end
end
describe '.erasable' do
subject { described_class.erasable }
......
......@@ -2995,6 +2995,16 @@ RSpec.describe Ci::Pipeline, :mailer do
end
end
describe '#batch_lookup_report_artifact_for_file_type' do
context 'with code quality report artifact' do
let(:pipeline) { create(:ci_pipeline, :with_codequality_report, project: project) }
it "returns the code quality artifact" do
expect(pipeline.batch_lookup_report_artifact_for_file_type(:codequality)).to eq(pipeline.job_artifacts.sample)
end
end
end
describe '#latest_report_builds' do
it 'returns build with test artifacts' do
test_build = create(:ci_build, :test_reports, pipeline: pipeline, project: project)
......
......@@ -7,6 +7,7 @@ RSpec.describe MergeRequestWidgetEntity do
let(:project) { create :project, :repository }
let(:resource) { create(:merge_request, source_project: project, target_project: project) }
let(:pipeline) { create(:ci_empty_pipeline, project: project) }
let(:user) { create(:user) }
let(:request) { double('request', current_user: user, project: project) }
......@@ -53,6 +54,44 @@ RSpec.describe MergeRequestWidgetEntity do
.to eq("/#{resource.project.full_path}/-/merge_requests/#{resource.iid}.diff")
end
it 'has blob path data' do
allow(resource).to receive_messages(
base_pipeline: pipeline,
head_pipeline: pipeline
)
expect(subject).to include(:blob_path)
expect(subject[:blob_path]).to include(:base_path)
expect(subject[:blob_path]).to include(:head_path)
end
describe 'codequality report artifacts', :request_store do
before do
project.add_developer(user)
allow(resource).to receive_messages(
base_pipeline: pipeline,
head_pipeline: pipeline
)
end
context "with report artifacts" do
before do
create(:ci_build, :codequality_report, pipeline: pipeline)
end
it "has data entry" do
expect(subject).to include(:codeclimate)
end
end
context "without artifacts" do
it "does not have data entry" do
expect(subject).not_to include(:codeclimate)
end
end
end
describe 'merge_request_add_ci_config_path' do
let!(:project_auto_devops) { create(:project_auto_devops, :disabled, project: project) }
......
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