Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/lib/gitlab/email/handler/create_note_handler_spec.rb')
-rw-r--r--spec/lib/gitlab/email/handler/create_note_handler_spec.rb54
1 files changed, 54 insertions, 0 deletions
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 e76a5d3fe32..c0ac40e3249 100644
--- a/spec/lib/gitlab/email/handler/create_note_handler_spec.rb
+++ b/spec/lib/gitlab/email/handler/create_note_handler_spec.rb
@@ -110,6 +110,60 @@ RSpec.describe Gitlab::Email::Handler::CreateNoteHandler do
end
end
+ context 'when email contains reply' do
+ shared_examples 'no content message' do
+ context 'when email contains quoted text only' do
+ let(:email_raw) { fixture_file('emails/no_content_with_quote.eml') }
+
+ it 'raises an EmptyEmailError' do
+ expect { receiver.execute }.to raise_error(Gitlab::Email::EmptyEmailError)
+ end
+ end
+
+ context 'when email contains quoted text and quick commands only' do
+ let(:email_raw) { fixture_file('emails/commands_only_reply.eml') }
+
+ it 'does not create a discussion' do
+ expect { receiver.execute }.not_to change { noteable.notes.count }
+ end
+ end
+ end
+
+ context 'when noteable is not an issue' do
+ let_it_be(:note) { create(:note_on_merge_request, project: project) }
+
+ it_behaves_like 'no content message'
+
+ context 'when email contains text, quoted text and quick commands' do
+ let(:email_raw) { fixture_file('emails/commands_in_reply.eml') }
+
+ it 'creates a discussion without appended reply' do
+ expect { receiver.execute }.to change { noteable.notes.count }.by(1)
+ new_note = noteable.notes.last
+
+ expect(new_note.note).not_to include('<details><summary>...</summary>')
+ end
+ end
+ end
+
+ context 'when noteable is an issue' do
+ let_it_be(:note) { create(:note_on_issue, project: project) }
+
+ it_behaves_like 'no content message'
+
+ context 'when email contains text, quoted text and quick commands' do
+ let(:email_raw) { fixture_file('emails/commands_in_reply.eml') }
+
+ it 'creates a discussion with appended reply' do
+ expect { receiver.execute }.to change { noteable.notes.count }.by(1)
+ new_note = noteable.notes.last
+
+ expect(new_note.note).to include('<details><summary>...</summary>')
+ end
+ end
+ end
+ end
+
context 'when note is not a discussion' do
let(:note) { create(:note_on_merge_request, project: project) }