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
01248d20
Commit
01248d20
authored
Jan 04, 2016
by
Robert Speicher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make AbuseReportMailer responsible for knowing if it should deliver
parent
0e60282e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
1 deletion
+47
-1
app/mailers/abuse_report_mailer.rb
app/mailers/abuse_report_mailer.rb
+9
-1
spec/mailers/abuse_report_mailer_spec.rb
spec/mailers/abuse_report_mailer_spec.rb
+38
-0
No files found.
app/mailers/abuse_report_mailer.rb
View file @
01248d20
...
@@ -2,6 +2,8 @@ class AbuseReportMailer < BaseMailer
...
@@ -2,6 +2,8 @@ class AbuseReportMailer < BaseMailer
include
Gitlab
::
CurrentSettings
include
Gitlab
::
CurrentSettings
def
notify
(
abuse_report_id
)
def
notify
(
abuse_report_id
)
return
unless
deliverable?
@abuse_report
=
AbuseReport
.
find
(
abuse_report_id
)
@abuse_report
=
AbuseReport
.
find
(
abuse_report_id
)
mail
(
mail
(
...
@@ -9,4 +11,10 @@ class AbuseReportMailer < BaseMailer
...
@@ -9,4 +11,10 @@ class AbuseReportMailer < BaseMailer
subject:
"
#{
@abuse_report
.
user
.
name
}
(
#{
@abuse_report
.
user
.
username
}
) was reported for abuse"
subject:
"
#{
@abuse_report
.
user
.
name
}
(
#{
@abuse_report
.
user
.
username
}
) was reported for abuse"
)
)
end
end
private
def
deliverable?
current_application_settings
.
admin_notification_email
.
present?
end
end
end
spec/mailers/abuse_report_mailer_spec.rb
0 → 100644
View file @
01248d20
require
'rails_helper'
describe
AbuseReportMailer
do
include
EmailSpec
::
Matchers
describe
'.notify'
do
context
'with admin_notification_email set'
do
before
do
stub_application_setting
(
admin_notification_email:
'admin@example.com'
)
end
it
'sends to the admin_notification_email'
do
report
=
create
(
:abuse_report
)
mail
=
described_class
.
notify
(
report
.
id
)
expect
(
mail
).
to
deliver_to
'admin@example.com'
end
it
'includes the user in the subject'
do
report
=
create
(
:abuse_report
)
mail
=
described_class
.
notify
(
report
.
id
)
expect
(
mail
).
to
have_subject
"
#{
report
.
user
.
name
}
(
#{
report
.
user
.
username
}
) was reported for abuse"
end
end
context
'with no admin_notification_email set'
do
it
'returns early'
do
stub_application_setting
(
admin_notification_email:
nil
)
expect
{
described_class
.
notify
(
spy
).
deliver_now
}.
not_to
change
{
ActionMailer
::
Base
.
deliveries
.
count
}
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