Skip to content

Fix bug with on site notification #2478

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 28, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion readthedocs/notifications/backends.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"""Notification to message backends"""

from django.conf import settings
from django.contrib.messages import add_message
from django.utils.module_loading import import_string
from messages_extends.constants import INFO_PERSISTENT
from messages_extends import add_message

from readthedocs.core.utils import send_email

Expand Down Expand Up @@ -75,4 +75,5 @@ def send(self, notification):
),
level=LEVEL_MAPPING.get(notification.level, INFO_PERSISTENT),
extra_tags='',
user=notification.user,
)
7 changes: 5 additions & 2 deletions readthedocs/rtd_tests/tests/test_notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import django_dynamic_fixture as fixture
from django.test import TestCase
from django.test.utils import override_settings
from django.contrib.auth.models import User

from readthedocs.notifications import Notification
from readthedocs.notifications.backends import EmailBackend, SiteBackend
Expand Down Expand Up @@ -76,11 +77,13 @@ class TestNotification(Notification):
context_object_name = 'foo'

build = fixture.get(Build)
user = fixture.get(User)
req = mock.MagicMock()
notify = TestNotification(object=build, request=req)
notify = TestNotification(object=build, request=req, user=user)
backend = SiteBackend(request=req)
backend.send(notify)

add_message.assert_has_calls([
mock.call(level=21, request=req, message=mock.ANY, extra_tags='')
mock.call(level=21, request=req, message=mock.ANY, extra_tags='',
user=user)
])