Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
f03510b0
Commit
f03510b0
authored
Aug 10, 2021
by
Eugenia Grieff
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Limit changes to notes in issues only
parent
4dd1bf75
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
22 deletions
+31
-22
lib/gitlab/email/handler/create_note_handler.rb
lib/gitlab/email/handler/create_note_handler.rb
+8
-2
spec/lib/gitlab/email/handler/create_note_handler_spec.rb
spec/lib/gitlab/email/handler/create_note_handler_spec.rb
+23
-20
No files found.
lib/gitlab/email/handler/create_note_handler.rb
View file @
f03510b0
...
...
@@ -25,7 +25,7 @@ module Gitlab
validate_permission!
(
:create_note
)
raise
NoteableNotFoundError
unless
noteable
raise
EmptyEmailError
if
message_with_appended_reply
.
blank?
raise
EmptyEmailError
if
note_message
.
blank?
verify_record!
(
record:
create_note
,
...
...
@@ -48,7 +48,13 @@ module Gitlab
end
def
create_note
sent_notification
.
create_reply
(
message_with_appended_reply
)
sent_notification
.
create_reply
(
note_message
)
end
def
note_message
return
message
unless
sent_notification
.
noteable_type
==
"Issue"
message_with_appended_reply
end
end
end
...
...
spec/lib/gitlab/email/handler/create_note_handler_spec.rb
View file @
f03510b0
...
...
@@ -66,8 +66,6 @@ RSpec.describe Gitlab::Email::Handler::CreateNoteHandler do
expect
(
new_note
.
author
).
to
eq
(
sent_notification
.
recipient
)
expect
(
new_note
.
position
).
to
eq
(
note
.
position
)
expect
(
new_note
.
note
).
to
include
(
'I could not disagree more.'
)
expect
(
new_note
.
note
).
to
include
(
'<details><summary>...</summary>'
)
expect
(
new_note
.
note
).
to
include
(
'> hey guys everyone knows adventure time sucks!'
)
expect
(
new_note
.
in_reply_to?
(
note
)).
to
be_truthy
expect
(
new_note
.
discussion_id
).
to
eq
(
note
.
discussion_id
)
...
...
@@ -112,33 +110,38 @@ RSpec.describe Gitlab::Email::Handler::CreateNoteHandler do
end
context
'when email contains quoted text'
do
context
'when email contains quoted text only'
do
let
(
:email_raw
)
{
fixture_file
(
'emails/no_content_reply.eml'
)
}
context
'when noteable is an issue'
do
let_it_be
(
:issue
)
{
create
(
:issue
,
project:
project
)}
let_it_be
(
:note
)
{
create
(
:note_on_issue
,
noteable:
issue
,
project:
project
)
}
it
'creates a discussion without appended reply'
do
expect
{
receiver
.
execute
}.
to
change
{
noteable
.
notes
.
count
}.
by
(
1
)
new_note
=
noteable
.
notes
.
last
context
'when email contains quoted text only'
do
let
(
:email_raw
)
{
fixture_file
(
'emails/no_content_reply.eml'
)
}
expect
(
new_note
.
note
).
not_to
include
(
'<details><summary>...</summary>'
)
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 email contains quoted text and quick commands only'
do
let
(
:email_raw
)
{
fixture_file
(
'emails/commands_only_reply.eml'
)
}
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
}
it
'does not create a discussion'
do
expect
{
receiver
.
execute
}.
not_to
change
{
noteable
.
notes
.
count
}
end
end
end
context
'when email contains text, quoted text and quick commands'
do
let
(
:email_raw
)
{
fixture_file
(
'emails/commands_in_reply.eml'
)
}
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
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>'
)
expect
(
new_note
.
note
).
to
include
(
'<details><summary>...</summary>'
)
end
end
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment