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
4723f0cf
Commit
4723f0cf
authored
Nov 09, 2016
by
Matt Lee
Committed by
mattl
Dec 07, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do not send emails to users who are inactive from the EE admin panel
parent
22b0091e
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
11 deletions
+49
-11
app/workers/admin_emails_worker.rb
app/workers/admin_emails_worker.rb
+4
-4
changelogs/unreleased-ee/mr-origin-863.yml
changelogs/unreleased-ee/mr-origin-863.yml
+5
-0
spec/workers/admin_emails_worker_spec.rb
spec/workers/admin_emails_worker_spec.rb
+40
-7
No files found.
app/workers/admin_emails_worker.rb
View file @
4723f0cf
...
...
@@ -3,7 +3,7 @@ class AdminEmailsWorker
include
DedicatedSidekiqQueue
def
perform
(
recipient_id
,
subject
,
body
)
recipient_list
(
recipient_id
).
pluck
(
:id
).
each
do
|
user_id
|
recipient_list
(
recipient_id
).
pluck
(
:id
).
uniq
.
each
do
|
user_id
|
Notify
.
send_admin_notification
(
user_id
,
subject
,
body
).
deliver_later
end
end
...
...
@@ -13,11 +13,11 @@ class AdminEmailsWorker
def
recipient_list
(
recipient_id
)
case
recipient_id
when
'all'
User
.
subscribed_for_admin_email
User
.
active
.
subscribed_for_admin_email
when
/group-(\d+)\z/
Group
.
find
(
$1
).
users
.
subscribed_for_admin_email
Group
.
find
(
$1
).
users
.
merge
(
Member
.
active
).
subscribed_for_admin_email
when
/project-(\d+)\z/
Project
.
find
(
$1
).
team
.
users
.
subscribed_for_admin_email
Project
.
find
(
$1
).
team
.
users
.
references
(
:members
).
merge
(
Member
.
active
).
subscribed_for_admin_email
end
end
end
changelogs/unreleased-ee/mr-origin-863.yml
0 → 100644
View file @
4723f0cf
---
title
:
Adds a check ensure only active, ie. non-blocked users can be emailed from
the admin panel
merge_request
:
author
:
spec/workers/admin_emails_worker_spec.rb
View file @
4723f0cf
...
...
@@ -2,18 +2,39 @@ require 'spec_helper'
describe
AdminEmailsWorker
do
context
"recipients"
do
let
(
:recipient_id
)
{
"group-
#{
group
.
id
}
"
}
let
(
:group
)
{
create
:group
}
let
(
:project
)
{
create
:project
}
before
do
2
.
times
do
group
.
add_user
(
create
(
:user
),
Gitlab
::
Access
::
DEVELOPER
)
user
=
create
(
:user
)
group
.
add_user
(
user
,
Gitlab
::
Access
::
DEVELOPER
)
project
.
add_user
(
user
,
Gitlab
::
Access
::
DEVELOPER
)
end
unsubscribed_user
=
create
(
:user
,
admin_email_unsubscribed_at:
5
.
days
.
ago
)
group
.
add_user
(
unsubscribed_user
,
Gitlab
::
Access
::
DEVELOPER
)
project
.
add_user
(
unsubscribed_user
,
Gitlab
::
Access
::
DEVELOPER
)
blocked_user
=
create
(
:user
,
state: :blocked
)
group
.
add_user
(
blocked_user
,
Gitlab
::
Access
::
DEVELOPER
)
project
.
add_user
(
blocked_user
,
Gitlab
::
Access
::
DEVELOPER
)
ActionMailer
::
Base
.
deliveries
=
[]
end
context
"sending emails to members of a group only"
do
let
(
:recipient_id
)
{
"group-
#{
group
.
id
}
"
}
it
"sends email to subscribed users"
do
perform_enqueued_jobs
do
AdminEmailsWorker
.
new
.
perform
(
recipient_id
,
'subject'
,
'body'
)
expect
(
ActionMailer
::
Base
.
deliveries
.
count
).
to
eql
2
end
end
end
context
"sending emails to members of a project only"
do
let
(
:recipient_id
)
{
"project-
#{
project
.
id
}
"
}
it
"sends email to subscribed users"
do
perform_enqueued_jobs
do
AdminEmailsWorker
.
new
.
perform
(
recipient_id
,
'subject'
,
'body'
)
...
...
@@ -21,4 +42,16 @@ describe AdminEmailsWorker do
end
end
end
context
"sending emails to users directly"
do
let
(
:recipient_id
)
{
"all"
}
it
"sends email to subscribed users"
do
perform_enqueued_jobs
do
AdminEmailsWorker
.
new
.
perform
(
recipient_id
,
'subject'
,
'body'
)
expect
(
ActionMailer
::
Base
.
deliveries
.
count
).
to
eql
4
end
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