Commit cc20c5cd authored by Gabriel Mazetto's avatar Gabriel Mazetto

Merge branch '342546-add-guard-clause-to-ensure-incoming-data-exists' into 'master'

Add guard clause to ensure incoming params

See merge request gitlab-org/gitlab!72241
parents 5a266eef 0f3b20cd
......@@ -10,6 +10,8 @@ class CreateNoteDiffFileWorker # rubocop:disable Scalability/IdempotentWorker
feature_category :code_review
def perform(diff_note_id)
return unless diff_note_id.present?
diff_note = DiffNote.find_by_id(diff_note_id) # rubocop: disable CodeReuse/ActiveRecord
diff_note&.create_diff_file
......
......@@ -23,5 +23,14 @@ RSpec.describe CreateNoteDiffFileWorker do
described_class.new.perform(non_existing_record_id)
end
end
context "when called with a missing diff_note id" do
it "returns nil without creating diff file" do
expect_any_instance_of(DiffNote).not_to receive(:create_diff_file)
.and_call_original
described_class.new.perform(nil)
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