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
cdc0e4d2
Commit
cdc0e4d2
authored
Jul 29, 2020
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reduce test data for service desk issue notifications
Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
d0ed916b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
122 additions
and
119 deletions
+122
-119
spec/services/notification_service_spec.rb
spec/services/notification_service_spec.rb
+122
-119
No files found.
spec/services/notification_service_spec.rb
View file @
cdc0e4d2
...
...
@@ -282,6 +282,80 @@ RSpec.describe NotificationService, :mailer do
subject
{
notification
.
new_note
(
note
)
}
context
'on service desk issue'
do
before
do
allow
(
Notify
).
to
receive
(
:service_desk_new_note_email
)
.
with
(
Integer
,
Integer
).
and_return
(
mailer
)
allow
(
::
Gitlab
::
IncomingEmail
).
to
receive
(
:enabled?
)
{
true
}
allow
(
::
Gitlab
::
IncomingEmail
).
to
receive
(
:supports_wildcard?
)
{
true
}
end
let
(
:subject
)
{
NotificationService
.
new
}
let
(
:mailer
)
{
double
(
deliver_later:
true
)
}
def
should_email!
expect
(
Notify
).
to
receive
(
:service_desk_new_note_email
)
.
with
(
issue
.
id
,
note
.
id
)
end
def
should_not_email!
expect
(
Notify
).
not_to
receive
(
:service_desk_new_note_email
)
end
def
execute!
subject
.
new_note
(
note
)
end
def
self
.
it_should_email!
it
'sends the email'
do
should_email!
execute!
end
end
def
self
.
it_should_not_email!
it
'doesn\'t send the email'
do
should_not_email!
execute!
end
end
let
(
:issue
)
{
create
(
:issue
,
author:
User
.
support_bot
)
}
let
(
:project
)
{
issue
.
project
}
let
(
:note
)
{
create
(
:note
,
noteable:
issue
,
project:
project
)
}
context
'a non-service-desk issue'
do
it_should_not_email!
end
context
'a service-desk issue'
do
before
do
issue
.
update!
(
service_desk_reply_to:
'service.desk@example.com'
)
project
.
update!
(
service_desk_enabled:
true
)
end
it_should_email!
context
'where the project has disabled the feature'
do
before
do
project
.
update
(
service_desk_enabled:
false
)
end
it_should_not_email!
end
context
'when the support bot has unsubscribed'
do
before
do
issue
.
unsubscribe
(
User
.
support_bot
,
project
)
end
it_should_not_email!
end
end
end
describe
'#new_note'
do
before
do
build_team
(
project
)
project
.
add_maintainer
(
issue
.
author
)
...
...
@@ -303,8 +377,7 @@ RSpec.describe NotificationService, :mailer do
update_custom_notification
(
:new_note
,
@u_custom_global
)
end
describe
'#new_note'
do
context
do
context
'with users'
do
before
do
add_users
(
project
)
add_user_subscriptions
(
issue
)
...
...
@@ -361,82 +434,10 @@ RSpec.describe NotificationService, :mailer do
it
{
expect
{
subject
}.
not_to
have_enqueued_email
(
@u_lazy_participant
.
id
,
note
.
id
,
mail:
"note_issue_email"
)
}
end
end
end
context
'on service desk issue'
do
before
do
allow
(
Notify
).
to
receive
(
:service_desk_new_note_email
)
.
with
(
Integer
,
Integer
).
and_return
(
mailer
)
allow
(
::
Gitlab
::
IncomingEmail
).
to
receive
(
:enabled?
)
{
true
}
allow
(
::
Gitlab
::
IncomingEmail
).
to
receive
(
:supports_wildcard?
)
{
true
}
end
let
(
:subject
)
{
NotificationService
.
new
}
let
(
:mailer
)
{
double
(
deliver_later:
true
)
}
def
should_email!
expect
(
Notify
).
to
receive
(
:service_desk_new_note_email
)
.
with
(
issue
.
id
,
note
.
id
)
end
def
should_not_email!
expect
(
Notify
).
not_to
receive
(
:service_desk_new_note_email
)
end
def
execute!
subject
.
new_note
(
note
)
end
def
self
.
it_should_email!
it
'sends the email'
do
should_email!
execute!
end
end
def
self
.
it_should_not_email!
it
'doesn\'t send the email'
do
should_not_email!
execute!
end
end
let
(
:issue
)
{
create
(
:issue
,
author:
User
.
support_bot
)
}
let
(
:project
)
{
issue
.
project
}
let
(
:note
)
{
create
(
:note
,
noteable:
issue
,
project:
project
)
}
context
'a non-service-desk issue'
do
it_should_not_email!
end
context
'a service-desk issue'
do
before
do
issue
.
update!
(
service_desk_reply_to:
'service.desk@example.com'
)
project
.
update!
(
service_desk_enabled:
true
)
end
it_should_email!
context
'where the project has disabled the feature'
do
before
do
project
.
update
(
service_desk_enabled:
false
)
end
it_should_not_email!
end
context
'in project that belongs to a group'
do
let_it_be
(
:parent_group
)
{
create
(
:group
)
}
context
'when the support bot has unsubscribed'
do
before
do
issue
.
unsubscribe
(
User
.
support_bot
,
project
)
end
it_should_not_email!
end
end
end
describe
'new note on issue in project that belongs to a group'
do
before
do
note
.
project
.
namespace_id
=
group
.
id
group
.
add_user
(
@u_watcher
,
GroupMember
::
MAINTAINER
)
...
...
@@ -470,7 +471,8 @@ RSpec.describe NotificationService, :mailer do
end
end
let
(
:group
)
{
create
(
:group
)
}
context
'which is a top-level group'
do
let!
(
:group
)
{
parent_group
}
it_behaves_like
'new note notifications'
...
...
@@ -478,17 +480,17 @@ RSpec.describe NotificationService, :mailer do
let
(
:notification_target
)
{
note
}
let
(
:notification_trigger
)
{
notification
.
new_note
(
note
)
}
end
end
context
'which is a subgroup'
do
let!
(
:parent
)
{
create
(
:group
)
}
let!
(
:group
)
{
create
(
:group
,
parent:
parent
)
}
let!
(
:group
)
{
create
(
:group
,
parent:
parent_group
)
}
it_behaves_like
'new note notifications'
it
'overrides child objects with global level'
do
user
=
create
(
:user
)
parent
.
add_developer
(
user
)
user
.
notification_settings_for
(
parent
).
watch!
parent_group
.
add_developer
(
user
)
user
.
notification_settings_for
(
parent_group
).
watch!
reset_delivered_emails!
notification
.
new_note
(
note
)
...
...
@@ -498,6 +500,7 @@ RSpec.describe NotificationService, :mailer do
end
end
end
end
context
'confidential issue note'
do
let
(
:project
)
{
create
(
:project
,
:public
)
}
...
...
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