Skip to content
Snippets Groups Projects
Verified Commit 77b7bd46 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets
Browse files

Add tests for codeclimate related backend code

parent c2642246
No related branches found
No related tags found
1 merge request!11379WIP Compare codeclimate artifacts on merge request page
Pipeline #
Loading
Loading
@@ -922,4 +922,10 @@ class MergeRequest < ActiveRecord::Base
def base_codeclimate_artifact
@base_codeclimate_artifact ||= base_pipeline&.codeclimate_artifact
end
def has_codeclimate_data?
has_ci? &&
codeclimate_artifact&.success? &&
base_codeclimate_artifact&.success?
end
end
Loading
Loading
@@ -184,9 +184,7 @@ class MergeRequestEntity < IssuableEntity
merge_request)
end
 
expose :codeclimate, if: lambda { |mr, _| mr.has_ci? &&
mr.codeclimate_artifact&.success? &&
mr.base_codeclimate_artifact&.success? } do
expose :codeclimate, if: lambda { |mr, _| mr.has_codeclimate_data? } do
expose :head do |merge_request|
raw_namespace_project_build_artifacts_url(merge_request.project.namespace,
merge_request.project,
Loading
Loading
Loading
Loading
@@ -1208,4 +1208,24 @@ describe Ci::Pipeline, models: true do
it_behaves_like 'not sending any notification'
end
end
describe '#codeclimate_artifact' do
let!(:build) do
create(
:ci_build,
:artifacts,
name: 'codeclimate',
pipeline: pipeline,
options: {
artifacts: {
paths: ['codeclimate.json']
}
}
)
end
it do
expect(pipeline.codeclimate_artifact).to eq(build)
end
end
end
Loading
Loading
@@ -1536,4 +1536,10 @@ describe MergeRequest, models: true do
end
end
end
describe '#base_pipeline' do
let!(:pipeline) { create(:ci_empty_pipeline, project: subject.project, sha: subject.diff_base_sha) }
it { expect(subject.base_pipeline).to eq(pipeline) }
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment