Commit 80b94298 authored by Shinya Maeda's avatar Shinya Maeda

Add tests

parent ba076a68
...@@ -37,7 +37,7 @@ module Ci ...@@ -37,7 +37,7 @@ module Ci
scope :with_expired_artifacts, ->() { with_artifacts.where('artifacts_expire_at < ?', Time.now) } scope :with_expired_artifacts, ->() { with_artifacts.where('artifacts_expire_at < ?', Time.now) }
scope :last_month, ->() { where('created_at > ?', Date.today - 1.month) } scope :last_month, ->() { where('created_at > ?', Date.today - 1.month) }
scope :manual_actions, ->() { where(when: :manual, status: COMPLETED_STATUSES + [:manual]) } scope :manual_actions, ->() { where(when: :manual, status: COMPLETED_STATUSES + [:manual]) }
scope :codeclimate, ->() { where(name: %w[codequality codeclimate]) } scope :codequality, ->() { where(name: %w[codequality codeclimate]) }
mount_uploader :artifacts_file, ArtifactUploader mount_uploader :artifacts_file, ArtifactUploader
mount_uploader :artifacts_metadata, ArtifactUploader mount_uploader :artifacts_metadata, ArtifactUploader
......
...@@ -442,7 +442,7 @@ module Ci ...@@ -442,7 +442,7 @@ module Ci
end end
def codeclimate_artifact def codeclimate_artifact
artifacts.codeclimate.find(&:has_codeclimate_json?) artifacts.codequality.find(&:has_codeclimate_json?)
end end
private private
......
...@@ -12,6 +12,28 @@ describe Ci::Build do ...@@ -12,6 +12,28 @@ describe Ci::Build do
let(:job) { create(:ci_build, pipeline: pipeline) } let(:job) { create(:ci_build, pipeline: pipeline) }
describe '.codequality' do
subject { described_class.codequality }
context 'when a job name is codequality' do
let!(:job) { create(:ci_build, pipeline: pipeline, name: 'codequality') }
it { is_expected.to include(job) }
end
context 'when a job name is codeclimate' do
let!(:job) { create(:ci_build, pipeline: pipeline, name: 'codeclimate') }
it { is_expected.to include(job) }
end
context 'when a job name is irrelevant' do
let!(:job) { create(:ci_build, pipeline: pipeline, name: 'codechecker') }
it { is_expected.not_to include(job) }
end
end
describe '#shared_runners_minutes_limit_enabled?' do describe '#shared_runners_minutes_limit_enabled?' do
subject { job.shared_runners_minutes_limit_enabled? } subject { job.shared_runners_minutes_limit_enabled? }
......
...@@ -1325,7 +1325,7 @@ describe Ci::Pipeline, :mailer do ...@@ -1325,7 +1325,7 @@ describe Ci::Pipeline, :mailer do
end end
describe '#codeclimate_artifact' do describe '#codeclimate_artifact' do
context 'has codeclimate build' do context 'has codequality job' do
let!(:build) do let!(:build) do
create( create(
:ci_build, :ci_build,
...@@ -1343,7 +1343,7 @@ describe Ci::Pipeline, :mailer do ...@@ -1343,7 +1343,7 @@ describe Ci::Pipeline, :mailer do
it { expect(pipeline.codeclimate_artifact).to eq(build) } it { expect(pipeline.codeclimate_artifact).to eq(build) }
end end
context 'no codeclimate build' do context 'no codequality job' do
before do before do
create(:ci_build, pipeline: pipeline) create(:ci_build, pipeline: pipeline)
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