Skip to content

Commit d99c236

Browse files
author
Ary Borenszweig
authored
Merge pull request #40 from NoRedInk/bug/allow-pr-with-nil-body
Handle the case of a PR without a body at all (nil)
2 parents 39cf7dc + dc8f388 commit d99c236

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

lib/deploy_complexity/pull_request.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def append_checklists(checklists, dry_run)
3838
return {} if pr.nil?
3939

4040
new_checklists =
41-
checklists.reject { |checklist, _| pr.body.include? checklist.id }
41+
checklists.reject { |checklist, _| pr.body&.include? checklist.id }
4242

4343
unless checklists.empty?
4444
new_body = body_with_checklist(new_checklists)
@@ -92,7 +92,7 @@ def org_and_repo
9292
end
9393

9494
def body_with_checklist(checklists)
95-
body = pr.body.clone
95+
body = pr.body ? pr.body.clone : ""
9696

9797
checklists.each do |checklist, _|
9898
body += checklist.for_pr_body

spec/lib/deploy_complexity/pull_request_spec.rb

+8
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,14 @@
6161
describe 'update_with_checklists' do
6262
let(:checklists) { { checklist => ["file"] } }
6363

64+
context "when the checklist is nil" do
65+
let(:body) { nil }
66+
67+
it "should add the checklist" do
68+
expect(subject.update_with_checklists(checklists, false)).to include(checklist)
69+
end
70+
end
71+
6472
context "when the checklist isn't present" do
6573
let(:body) { "" }
6674

0 commit comments

Comments
 (0)