Skip to content
代码片段 群组 项目
提交 ba7bf2cc 编辑于 作者: Kasia Misirli's avatar Kasia Misirli
浏览文件

Allow danger warning in both ui and ci

上级 60a9d09d
No related branches found
No related tags found
无相关合并请求
......@@ -12,29 +12,49 @@
let(:fake_danger) { DangerSpecHelper.fake_danger.include(described_class) }
before do
allow(fake_helper).to receive(:ci?).and_return(ci_env)
end
describe '#check!' do
context 'when not in ci environment' do
let(:ci_env) { false }
context 'when checking for mr labels' do
context 'when mr does not have a ci::templates label' do
it 'does not add the danger message, markdown and warning' do
expect(ci_templates).not_to receive(:message)
expect(ci_templates).not_to receive(:markdown)
expect(ci_templates).not_to receive(:warn)
ci_templates.check!
end
end
it 'does not add the warnings' do
expect(ci_templates).not_to receive(:message)
expect(ci_templates).not_to receive(:markdown)
expect(ci_templates).not_to receive(:warn)
context 'when mr has a ci::templates label' do
before do
allow(fake_helper).to receive(:mr_labels).and_return(['ci::templates'])
allow(ci_templates).to receive(:message)
allow(ci_templates).to receive(:markdown)
end
it 'adds the danger message and markdown' do
expect(ci_templates).to receive(:message)
expect(ci_templates).to receive(:markdown)
ci_templates.check!
ci_templates.check!
end
end
end
context 'when in ci environment' do
let(:ci_env) { true }
let(:modified_files) { %w[lib/gitlab/ci/templates/ci_template.rb] }
let(:fake_changes) { instance_double(Gitlab::Dangerfiles::Changes, files: modified_files) }
context 'when checking for changes to ci templates' do
context 'when there are no updated ci templates' do
it 'does not add the danger message, markdown and warning' do
expect(ci_templates).not_to receive(:message)
expect(ci_templates).not_to receive(:markdown)
expect(ci_templates).not_to receive(:warn)
ci_templates.check!
end
end
context 'when there are updates to the ci templates' do
let(:modified_files) { %w[lib/gitlab/ci/templates/ci_template.rb] }
let(:fake_changes) { instance_double(Gitlab::Dangerfiles::Changes, files: modified_files) }
before do
allow(fake_changes).to receive(:by_category).with(:ci_template).and_return(fake_changes)
allow(fake_helper).to receive(:changes).and_return(fake_changes)
......@@ -60,16 +80,6 @@
end
end
end
context 'when there are no updated ci templates' do
it 'does not add the danger message, markdown and warning' do
expect(ci_templates).not_to receive(:message)
expect(ci_templates).not_to receive(:markdown)
expect(ci_templates).not_to receive(:warn)
ci_templates.check!
end
end
end
end
end
......@@ -20,8 +20,6 @@ module CiTemplates
MSG
def check!
return unless helper.ci?
return unless helper.mr_labels.include?('ci::templates') || changes.any?
message('This merge request adds or changes files that require a ' \
......
......@@ -5,7 +5,6 @@ module Danger
module ProjectHelper
CI_ONLY_RULES ||= %w[
ce_ee_vue_templates
ci_templates
datateam
feature_flag
roulette
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册