diff --git a/lib/gitlab/email/handler/create_note_handler.rb b/lib/gitlab/email/handler/create_note_handler.rb index 0553ca738a2af5124439d5046b926bab77739a18..817956831e31b4823fe0eac03e84b8408525f523 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 53937935a02ee0f92957190d43b6cc0bbaaf22f6..30514b531dc889fd409ea7c28b69acd5165a70d2 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