From 0f80ba953ed246321d77a45dfccd4218125777b1 Mon Sep 17 00:00:00 2001 From: Marc Saleiko <msaleiko@gitlab.com> Date: Wed, 6 Dec 2023 15:37:59 +0100 Subject: [PATCH] Fixes error when noteable is Commit in CreateNoteHandler Changelog: fixed --- lib/gitlab/email/handler/create_note_handler.rb | 1 + .../email/handler/create_note_handler_spec.rb | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/lib/gitlab/email/handler/create_note_handler.rb b/lib/gitlab/email/handler/create_note_handler.rb index 0553ca738a2af..817956831e31b 100644 --- a/lib/gitlab/email/handler/create_note_handler.rb +++ b/lib/gitlab/email/handler/create_note_handler.rb @@ -75,6 +75,7 @@ def validate_from_address! end def reopen_issue_on_external_participant_note + return unless noteable.respond_to?(:closed?) return unless noteable.closed? return unless author == Users::Internal.support_bot return unless project.service_desk_setting&.reopen_issue_on_external_participant_note? diff --git a/spec/lib/gitlab/email/handler/create_note_handler_spec.rb b/spec/lib/gitlab/email/handler/create_note_handler_spec.rb index 53937935a02ee..30514b531dc88 100644 --- a/spec/lib/gitlab/email/handler/create_note_handler_spec.rb +++ b/spec/lib/gitlab/email/handler/create_note_handler_spec.rb @@ -262,6 +262,20 @@ expect(noteable).to be_closed end + context 'when noteable is a commit' do + let!(:note) { create(:note_on_commit, project: project) } + let!(:noteable) { note.noteable } + + let!(:sent_notification) do + allow(Gitlab::ServiceDesk).to receive(:enabled?).with(project: project).and_return(true) + SentNotification.record_note(note, Users::Internal.support_bot.id) + end + + it 'does not reopen issue but adds external participants comment' do + expect { receiver.execute }.to change { noteable.notes.count }.by(1) + end + end + context 'when reopen_issue_on_external_participant_note is true' do shared_examples 'an automatically reopened issue' do it 'reopens issue, adds external participants comment and reopen comment' do -- GitLab