Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-02-17 00:07:47 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-02-17 00:07:47 +0300
commit2c34e41161b78fddbdff9a858086e95558e06ba0 (patch)
tree7db8b02c06a3ee2319762c9417d37e81397a5d65 /spec/tooling
parent5c4df0629a70c28eb479b513a3e6860e7a35d1c9 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/tooling')
-rw-r--r--spec/tooling/danger/product_intelligence_spec.rb47
1 files changed, 46 insertions, 1 deletions
diff --git a/spec/tooling/danger/product_intelligence_spec.rb b/spec/tooling/danger/product_intelligence_spec.rb
index fab8b0c61fa..c4cd0e5bfb6 100644
--- a/spec/tooling/danger/product_intelligence_spec.rb
+++ b/spec/tooling/danger/product_intelligence_spec.rb
@@ -18,7 +18,7 @@ RSpec.describe Tooling::Danger::ProductIntelligence do
let(:has_product_intelligence_label) { true }
before do
- allow(fake_helper).to receive(:changed_lines).and_return(changed_lines)
+ allow(fake_helper).to receive(:changed_lines).and_return(changed_lines) if defined?(changed_lines)
allow(fake_helper).to receive(:labels_to_add).and_return(labels_to_add)
allow(fake_helper).to receive(:ci?).and_return(ci_env)
allow(fake_helper).to receive(:mr_has_labels?).with('product intelligence').and_return(has_product_intelligence_label)
@@ -175,4 +175,49 @@ RSpec.describe Tooling::Danger::ProductIntelligence do
end
end
end
+
+ describe '#check_usage_data_insertions!' do
+ context 'when usage_data.rb is modified' do
+ let(:modified_files) { ['lib/gitlab/usage_data.rb'] }
+
+ before do
+ allow(fake_helper).to receive(:changed_lines).with("lib/gitlab/usage_data.rb").and_return(changed_lines)
+ end
+
+ context 'and has insertions' do
+ let(:changed_lines) { ['+ ci_runners: count(::Ci::CiRunner),'] }
+
+ it 'produces warning' do
+ expect(product_intelligence).to receive(:warn).with(/usage_data\.rb has been deprecated/)
+
+ product_intelligence.check_usage_data_insertions!
+ end
+ end
+
+ context 'and changes are not insertions' do
+ let(:changed_lines) { ['- ci_runners: count(::Ci::CiRunner),'] }
+
+ it 'doesnt do anything' do
+ expect(product_intelligence).not_to receive(:warn)
+
+ product_intelligence.check_usage_data_insertions!
+ end
+ end
+ end
+
+ context 'when usage_data.rb is not modified' do
+ context 'and another file has insertions' do
+ let(:modified_files) { ['tooling/danger/product_intelligence.rb'] }
+
+ it 'doesnt do anything' do
+ expect(fake_helper).to receive(:changed_lines).with("lib/gitlab/usage_data.rb").and_return([])
+ allow(fake_helper).to receive(:changed_lines).with("tooling/danger/product_intelligence.rb").and_return(["+ Inserting"])
+
+ expect(product_intelligence).not_to receive(:warn)
+
+ product_intelligence.check_usage_data_insertions!
+ end
+ end
+ end
+ end
end