summaryrefslogtreecommitdiff
path: root/spec/tooling/danger/stable_branch_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/tooling/danger/stable_branch_spec.rb')
-rw-r--r--spec/tooling/danger/stable_branch_spec.rb99
1 files changed, 70 insertions, 29 deletions
diff --git a/spec/tooling/danger/stable_branch_spec.rb b/spec/tooling/danger/stable_branch_spec.rb
index 9eee077d493..f4008e09ef2 100644
--- a/spec/tooling/danger/stable_branch_spec.rb
+++ b/spec/tooling/danger/stable_branch_spec.rb
@@ -92,11 +92,19 @@ RSpec.describe Tooling::Danger::StableBranch, feature_category: :delivery do
let(:pipeline_bridges_response) do
[
- { 'name' => 'e2e:package-and-test',
- 'status' => 'success' }
+ {
+ 'name' => 'e2e:package-and-test',
+ 'status' => 'success',
+ 'downstream_pipeline' => {
+ 'id' => '123',
+ 'status' => package_and_qa_state
+ }
+ }
]
end
+ let(:package_and_qa_state) { 'success' }
+
let(:parsed_response) do
[
{ 'version' => '15.1.1' },
@@ -154,6 +162,13 @@ RSpec.describe Tooling::Danger::StableBranch, feature_category: :delivery do
it_behaves_like 'with a failure', described_class::BUG_ERROR_MESSAGE
end
+ context 'with only documentation changes and no bug label' do
+ let(:bug_label_present) { false }
+ let(:changes_by_category_response) { { docs: ['foo.md'] } }
+
+ it_behaves_like 'without a failure'
+ end
+
context 'with a pipeline:expedite label' do
let(:pipeline_expedite_label_present) { true }
@@ -169,31 +184,26 @@ RSpec.describe Tooling::Danger::StableBranch, feature_category: :delivery do
end
context 'when package-and-test job is in manual state' do
- described_class::FAILING_PACKAGE_AND_TEST_STATUSES.each do |status|
- let(:pipeline_bridges_response) do
- [
- { 'name' => 'e2e:package-and-test',
- 'status' => status }
- ]
- end
+ let(:package_and_qa_state) { 'manual' }
- it_behaves_like 'with a failure', described_class::NEEDS_PACKAGE_AND_TEST_MESSAGE
- it_behaves_like 'bypassing when flaky test or docs only'
- end
+ it_behaves_like 'with a failure', described_class::NEEDS_PACKAGE_AND_TEST_MESSAGE
+ it_behaves_like 'bypassing when flaky test or docs only'
end
context 'when package-and-test job is in a non-successful state' do
- let(:pipeline_bridges_response) do
- [
- { 'name' => 'e2e:package-and-test',
- 'status' => 'running' }
- ]
- end
+ let(:package_and_qa_state) { 'running' }
it_behaves_like 'with a warning', described_class::WARN_PACKAGE_AND_TEST_MESSAGE
it_behaves_like 'bypassing when flaky test or docs only'
end
+ context 'when package-and-test job is canceled' do
+ let(:package_and_qa_state) { 'canceled' }
+
+ it_behaves_like 'with a failure', described_class::NEEDS_PACKAGE_AND_TEST_MESSAGE
+ it_behaves_like 'bypassing when flaky test or docs only'
+ end
+
context 'when no pipeline is found' do
before do
allow(gitlab_gem_client).to receive(:mr_json).and_return({})
@@ -266,23 +276,54 @@ RSpec.describe Tooling::Danger::StableBranch, feature_category: :delivery do
end
end
- describe '#non_security_stable_branch?' do
- subject { stable_branch.non_security_stable_branch? }
-
- where(:stable_branch?, :security_mr?, :expected_result) do
- true | true | false
- false | true | false
- true | false | true
- false | false | false
+ describe '#encourage_package_and_qa_execution?' do
+ subject { stable_branch.encourage_package_and_qa_execution? }
+
+ where(:stable_branch?, :security_mr?, :documentation?, :flaky?, :result) do
+ # security merge requests
+ true | true | true | true | false
+ true | true | true | false | false
+ true | true | false | true | false
+ true | true | false | false | false
+ # canonical merge requests with doc and flaky changes only
+ true | false | true | true | false
+ true | false | true | false | false
+ true | false | false | true | false
+ # canonical merge requests with app code
+ true | false | false | false | true
end
with_them do
before do
- allow(fake_helper).to receive(:mr_target_branch).and_return(stable_branch? ? '15-1-stable-ee' : 'main')
- allow(fake_helper).to receive(:security_mr?).and_return(security_mr?)
+ allow(fake_helper)
+ .to receive(:mr_target_branch)
+ .and_return(stable_branch? ? '15-1-stable-ee' : 'main')
+
+ allow(fake_helper)
+ .to receive(:security_mr?)
+ .and_return(security_mr?)
+
+ allow(fake_helper)
+ .to receive(:has_only_documentation_changes?)
+ .and_return(documentation?)
+
+ changes_by_category =
+ if documentation?
+ { docs: ['foo.md'] }
+ else
+ { graphql: ['bar.rb'] }
+ end
+
+ allow(fake_helper)
+ .to receive(:changes_by_category)
+ .and_return(changes_by_category)
+
+ allow(fake_helper)
+ .to receive(:mr_has_labels?)
+ .and_return(flaky?)
end
- it { is_expected.to eq(expected_result) }
+ it { is_expected.to eq(result) }
end
end
end