diff --git a/spec/tooling/danger/product_intelligence_spec.rb b/spec/tooling/danger/product_intelligence_spec.rb index c4cd0e5bfb6e9640606d98cc87886925e09439ae..bc6b9debfe0ccb5100d1345a7c4058541ac1e9b3 100644 --- a/spec/tooling/danger/product_intelligence_spec.rb +++ b/spec/tooling/danger/product_intelligence_spec.rb @@ -32,10 +32,12 @@ let(:approved_label) { 'product intelligence::approved' } let(:changed_files) { ['metrics/counts_7d/test_metric.yml'] } let(:changed_lines) { ['+tier: ee'] } + let(:fake_changes) { instance_double(Gitlab::Dangerfiles::Changes, files: changed_files) } before do + allow(fake_changes).to receive(:by_category).with(:product_intelligence).and_return(fake_changes) + allow(fake_helper).to receive(:changes).and_return(fake_changes) allow(fake_helper).to receive(:all_changed_files).and_return(changed_files) - allow(fake_helper).to receive(:changes_by_category).and_return(product_intelligence: changed_files, database: ['other_files.yml']) allow(fake_helper).to receive(:markdown_list).with(changed_files).and_return(markdown_formatted_list) end @@ -61,6 +63,15 @@ expect(labels_to_add).to match_array [previous_label_to_add, review_pending_label] end + + it 'receives all the changed files by calling the correct helper method', :aggregate_failures do + expect(fake_helper).not_to receive(:changes_by_category) + expect(fake_helper).to receive(:changes) + expect(fake_changes).to receive(:by_category).with(:product_intelligence) + expect(fake_changes).to receive(:files) + + subject + end end context 'with growth experiment label' do diff --git a/tooling/danger/product_intelligence.rb b/tooling/danger/product_intelligence.rb index d25f966504f26e549ffebbe1a2ae097576fd5f9b..00dc31b9bb989cec1ab4b59f69ac76843abc4aa6 100644 --- a/tooling/danger/product_intelligence.rb +++ b/tooling/danger/product_intelligence.rb @@ -33,8 +33,8 @@ module ProductIntelligence ].freeze def check! - # exit if not matching files or if no product intelligence labels - product_intelligence_paths_to_review = helper.changes_by_category[:product_intelligence] + product_intelligence_paths_to_review = helper.changes.by_category(:product_intelligence).files + labels_to_add = missing_labels return if product_intelligence_paths_to_review.empty? || skip_review?