Skip to content

Commit

Permalink
Merge pull request #90 from ambitioninc/develop
Browse files Browse the repository at this point in the history
2.1.2
  • Loading branch information
jaredlewis authored Jun 2, 2021
2 parents 48c3628 + 9b9011f commit a7205da
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
3 changes: 3 additions & 0 deletions entity_emailer/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ def send_unsent_scheduled_emails(cls):
to_email_addresses = get_subscribed_email_addresses(email)

# If there are no recipients we can just skip rendering
# and mark the email as sent
if not to_email_addresses:
email.sent = current_time
email.save(update_fields=['sent'])
continue

# If any exceptions occur we will catch the exception and store it as a reference
Expand Down
16 changes: 14 additions & 2 deletions entity_emailer/tests/interface_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,11 +391,23 @@ def setUp(self):
def test_sends_all_scheduled_emails_no_email_addresses(self, render_mock, address_mock):
render_mock.return_value = ['<p>This is a test html email.</p>', 'This is a test text email.']
address_mock.return_value = []
g_email(context={}, scheduled=datetime.min)
g_email(context={}, scheduled=datetime.min)
original_emails = [
g_email(context={}, scheduled=datetime.min),
g_email(context={}, scheduled=datetime.min)
]
EntityEmailerInterface.send_unsent_scheduled_emails()
self.assertEqual(len(mail.outbox), 0)

# Assert that the emails are still marked as sent
sent_emails = Email.objects.filter(
id__in=[email.id for email in original_emails],
sent__isnull=False
)
self.assertEqual(
set(sent_emails),
set(original_emails)
)

@override_settings(DISABLE_DURABILITY_CHECKING=True)
@patch('entity_emailer.interface.get_subscribed_email_addresses')
@patch.object(Event, 'render', spec_set=True)
Expand Down
2 changes: 1 addition & 1 deletion entity_emailer/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '2.1.1'
__version__ = '2.1.2'
4 changes: 4 additions & 0 deletions release_notes.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
Release Notes
=============

v2.1.2
------
* Fix issue for not marking email as sent when no email addresses exist

v2.1.1
------
* Fixed error handling with email backend exceptions that implement to_dict
Expand Down

0 comments on commit a7205da

Please sign in to comment.