Commit 7e85d6c5 authored by Terri Chu's avatar Terri Chu

Merge branch '342546-guard-against-unfound-diff_note-records' into 'master'

Guard against exceptions from unfound DiffNotes

See merge request gitlab-org/gitlab!72242
parents 476accf1 580072f8
......@@ -10,8 +10,8 @@ class CreateNoteDiffFileWorker # rubocop:disable Scalability/IdempotentWorker
feature_category :code_review
def perform(diff_note_id)
diff_note = DiffNote.find(diff_note_id)
diff_note = DiffNote.find_by_id(diff_note_id) # rubocop: disable CodeReuse/ActiveRecord
diff_note.create_diff_file
diff_note&.create_diff_file
end
end
......@@ -14,5 +14,14 @@ RSpec.describe CreateNoteDiffFileWorker do
described_class.new.perform(diff_note.id)
end
context "when the supplied diff_note_id doesn't belong to an existing DiffNote" do
it "returns nil without raising an error" do
expect_any_instance_of(DiffNote).not_to receive(:create_diff_file)
.and_call_original
described_class.new.perform(non_existing_record_id)
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment