wrap from pretty name in quotes (#5725)
This commit is contained in:
Родитель
80a33c1579
Коммит
e2414d4e1a
|
@ -266,7 +266,7 @@ class TestLogAndNotify(TestCase):
|
|||
assert logs[0].details['comments'] == u'Thïs is á reply'
|
||||
|
||||
assert send_mail_mock.call_count == 2 # One author, one reviewer.
|
||||
sender = '%s <notifications@%s>' % (
|
||||
sender = '"%s" <notifications@%s>' % (
|
||||
self.developer.name, settings.INBOUND_EMAIL_DOMAIN)
|
||||
assert sender == send_mail_mock.call_args_list[0][1]['from_email']
|
||||
recipients = self._recipients(send_mail_mock)
|
||||
|
@ -306,7 +306,7 @@ class TestLogAndNotify(TestCase):
|
|||
assert logs[0].details['comments'] == u'Thîs ïs a revïewer replyîng'
|
||||
|
||||
assert send_mail_mock.call_count == 2 # Both authors.
|
||||
sender = '%s <notifications@%s>' % (
|
||||
sender = '"%s" <notifications@%s>' % (
|
||||
self.reviewer.name, settings.INBOUND_EMAIL_DOMAIN)
|
||||
assert sender == send_mail_mock.call_args_list[0][1]['from_email']
|
||||
recipients = self._recipients(send_mail_mock)
|
||||
|
@ -339,7 +339,7 @@ class TestLogAndNotify(TestCase):
|
|||
assert not logs[0].details # No details json because no comment.
|
||||
|
||||
assert send_mail_mock.call_count == 2 # One author, one reviewer.
|
||||
sender = '%s <notifications@%s>' % (
|
||||
sender = '"%s" <notifications@%s>' % (
|
||||
self.developer.name, settings.INBOUND_EMAIL_DOMAIN)
|
||||
assert sender == send_mail_mock.call_args_list[0][1]['from_email']
|
||||
recipients = self._recipients(send_mail_mock)
|
||||
|
@ -368,7 +368,7 @@ class TestLogAndNotify(TestCase):
|
|||
assert len(logs) == 1
|
||||
|
||||
recipients = self._recipients(send_mail_mock)
|
||||
sender = '%s <notifications@%s>' % (
|
||||
sender = '"%s" <notifications@%s>' % (
|
||||
self.developer.name, settings.INBOUND_EMAIL_DOMAIN)
|
||||
assert sender == send_mail_mock.call_args_list[0][1]['from_email']
|
||||
assert len(recipients) == 2
|
||||
|
@ -493,6 +493,20 @@ class TestLogAndNotify(TestCase):
|
|||
review_url, 'Developer Reply',
|
||||
'you reviewed this add-on.')
|
||||
|
||||
@mock.patch('olympia.activity.utils.send_mail')
|
||||
def test_from_name_escape(self, send_mail_mock):
|
||||
self.reviewer.update(display_name='mr "quote" escape')
|
||||
|
||||
# One from the reviewer.
|
||||
self._create(amo.LOG.REJECT_VERSION, self.reviewer)
|
||||
action = amo.LOG.REVIEWER_REPLY_VERSION
|
||||
comments = u'Thîs ïs a revïewer replyîng'
|
||||
log_and_notify(action, comments, self.reviewer, self.version)
|
||||
|
||||
sender = '"%s" <notifications@%s>' % (
|
||||
'mr \"quote\" escape', settings.INBOUND_EMAIL_DOMAIN)
|
||||
assert sender == send_mail_mock.call_args_list[0][1]['from_email']
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_send_activity_mail():
|
||||
|
|
|
@ -251,27 +251,22 @@ def log_and_notify(action, comments, note_creator, version, perm_setting=None,
|
|||
subject = u'Mozilla Add-ons: %s %s %s' % (
|
||||
version.addon.name, version.version, action.short)
|
||||
template = template_from_user(note_creator, version)
|
||||
|
||||
from_name = unicode(note_creator.name).replace('"', '\"')
|
||||
from_email = '"%s" <%s>' % (from_name, NOTIFICATIONS_FROM_EMAIL)
|
||||
send_activity_mail(
|
||||
subject, template.render(Context(
|
||||
author_context_dict, autoescape=False)),
|
||||
version, addon_authors,
|
||||
'%s <%s>' % (note_creator.name, NOTIFICATIONS_FROM_EMAIL),
|
||||
perm_setting)
|
||||
version, addon_authors, from_email, perm_setting)
|
||||
|
||||
send_activity_mail(
|
||||
subject, template.render(Context(
|
||||
reviewer_context_dict, autoescape=False)),
|
||||
version, reviewers,
|
||||
'%s <%s>' % (note_creator.name, NOTIFICATIONS_FROM_EMAIL),
|
||||
perm_setting)
|
||||
version, reviewers, from_email, perm_setting)
|
||||
|
||||
send_activity_mail(
|
||||
subject, template.render(Context(
|
||||
staff_cc_context_dict, autoescape=False)),
|
||||
version, staff_cc,
|
||||
'%s <%s>' % (note_creator.name, NOTIFICATIONS_FROM_EMAIL),
|
||||
perm_setting)
|
||||
version, staff_cc, from_email, perm_setting)
|
||||
|
||||
if action == amo.LOG.DEVELOPER_REPLY_VERSION:
|
||||
version.update(has_info_request=False)
|
||||
|
|
Загрузка…
Ссылка в новой задаче