Skip to content
代码片段 群组 项目
提交 a3a9c0e2 编辑于 作者: 路志远's avatar 路志远
浏览文件

Add spec for mergeable_ci_state

上级 1b5b0ebb
No related branches found
No related tags found
无相关合并请求
......@@ -7,4 +7,54 @@
it_behaves_like "content validation with project", :merge_request, :title
it_behaves_like "content validation with project", :merge_request, :description
end
describe '#mergeable_ci_state?' do
let(:mono_central_pipeline) { build(:ci_empty_pipeline) }
let(:merge_request) { build(:merge_request, source_project: project) }
let(:project) { build(:project, :repository, only_allow_merge_if_pipeline_succeeds: true) }
context 'when monorepo is enabled' do
before do
allow(::MergeRequests::MonorepoService).to receive(:monorepo_enabled?).and_return(true)
end
context 'when no diff_head_pipeline is associated' do
before do
allow_any_instance_of(::MergeRequests::MonorepoService)
.to receive(:central_pipeline)
.and_return(mono_central_pipeline)
end
context 'and has no mono_central_pipeline associated' do
let(:mono_central_pipeline) { nil }
it { expect(merge_request.mergeable_ci_state?).to be_falsey }
end
context 'and a failed mono_central_pipeline is associated' do
before do
mono_central_pipeline.status = 'failed'
end
it { expect(merge_request.mergeable_ci_state?).to be_falsey }
end
context 'and a successful mono_central_pipeline is associated' do
before do
mono_central_pipeline.status = 'success'
end
it { expect(merge_request.mergeable_ci_state?).to be_truthy }
end
context 'and a skipped mono_central_pipeline is associated' do
before do
mono_central_pipeline.status = 'skipped'
end
it { expect(merge_request.mergeable_ci_state?).to be_falsey }
end
end
end
end
end
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册