Commit 87d1a814 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Add tests for MergeRequest#has_codeclimate_data?

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 2253c084
......@@ -1000,7 +1000,7 @@ class MergeRequest < ActiveRecord::Base
end
def has_codeclimate_data?
head_codeclimate_artifact&.success? &&
base_codeclimate_artifact&.success?
!!(head_codeclimate_artifact&.success? &&
base_codeclimate_artifact&.success?)
end
end
......@@ -2093,4 +2093,21 @@ describe MergeRequest, models: true do
expect(subject.head_codeclimate_artifact).to eq(1)
end
end
describe '#has_codeclimate_data?' do
context 'with codeclimate artifact' do
before do
artifact = double()
allow(artifact).to receive(:success?).and_return(true)
allow(subject.head_pipeline).to receive(:codeclimate_artifact).and_return(artifact)
allow(subject.base_pipeline).to receive(:codeclimate_artifact).and_return(artifact)
end
it { expect(subject.has_codeclimate_data?).to be_truthy }
end
context 'without codeclimate artifact' do
it { expect(subject.has_codeclimate_data?).to be_falsey }
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