From a196e04c7f7ef580fdc1da66952c87e53cfb6da3 Mon Sep 17 00:00:00 2001 From: Barry Gordon Date: Fri, 10 Mar 2023 18:52:51 +0000 Subject: [PATCH] Do not nil out the PR message for jobs updating a PR --- updater/lib/dependabot/dependency_change.rb | 2 - .../spec/dependabot/dependency_change_spec.rb | 38 +++++-------------- 2 files changed, 10 insertions(+), 30 deletions(-) diff --git a/updater/lib/dependabot/dependency_change.rb b/updater/lib/dependabot/dependency_change.rb index 20237329828..de5f6041582 100644 --- a/updater/lib/dependabot/dependency_change.rb +++ b/updater/lib/dependabot/dependency_change.rb @@ -21,8 +21,6 @@ def initialize(job:, dependencies:, updated_dependency_files:, group_rule: nil) end def pr_message - # If we are updating an existing PullRequest, we do not generate a new message as part of the change - return nil if job.updating_a_pull_request? return @pr_message if defined?(@pr_message) @pr_message = Dependabot::PullRequestCreator::MessageBuilder.new( diff --git a/updater/spec/dependabot/dependency_change_spec.rb b/updater/spec/dependabot/dependency_change_spec.rb index aefa2b6ad52..bbc17528f4c 100644 --- a/updater/spec/dependabot/dependency_change_spec.rb +++ b/updater/spec/dependabot/dependency_change_spec.rb @@ -92,35 +92,17 @@ allow(Dependabot::PullRequestCreator::MessageBuilder).to receive(:new).and_return(message_builder_mock) end - context "when the change is for a new pull request" do - before do - allow(job).to receive(:updating_a_pull_request?).and_return(false) - end - - it "delegates to the Dependabot::PullRequestCreator::MessageBuilder with the correct configuration" do - expect(Dependabot::PullRequestCreator::MessageBuilder). - to receive(:new).with( - source: github_source, - files: updated_dependency_files, - dependencies: dependencies, - credentials: job_credentials, - commit_message_options: commit_message_options - ) - - expect(dependency_change.pr_message).to eql("Hello World!") - end - end - - context "when the change is updating an existing pull request" do - before do - allow(job).to receive(:updating_a_pull_request?).and_return(true) - end - - it "it does not invoke Dependabot::PullRequestCreator::MessageBuilder" do - expect(Dependabot::PullRequestCreator::MessageBuilder).not_to receive(:new) + it "delegates to the Dependabot::PullRequestCreator::MessageBuilder with the correct configuration" do + expect(Dependabot::PullRequestCreator::MessageBuilder). + to receive(:new).with( + source: github_source, + files: updated_dependency_files, + dependencies: dependencies, + credentials: job_credentials, + commit_message_options: commit_message_options + ) - expect(dependency_change.pr_message).to be_nil - end + expect(dependency_change.pr_message).to eql("Hello World!") end end