digests: Fix new stream links.

Fixes: #7479.
This commit is contained in:
Harshit Bansal 2017-11-22 10:00:23 +00:00 committed by Tim Abbott
parent e071d27b6b
commit 2e7d0cb4cb
2 changed files with 13 additions and 2 deletions

View File

@ -162,7 +162,7 @@ def gather_new_streams(user_profile: UserProfile,
new_streams = list(get_active_streams(user_profile.realm).filter(
invite_only=False, date_created__gt=threshold))
base_url = u"%s/ # narrow/stream/" % (user_profile.realm.uri,)
base_url = u"%s/#narrow/stream/" % (user_profile.realm.uri,)
streams_html = []
streams_plain = []

View File

@ -26,6 +26,7 @@ from zerver.models import (
)
from zerver.lib.actions import (
create_stream_if_needed,
encode_email_address,
do_create_user
)
@ -35,7 +36,7 @@ from zerver.lib.email_mirror import (
get_missed_message_token_from_address,
)
from zerver.lib.digest import handle_digest_email, enqueue_emails
from zerver.lib.digest import gather_new_streams, handle_digest_email, enqueue_emails
from zerver.lib.send_email import FromAddress
from zerver.lib.notifications import (
handle_missedmessage_emails,
@ -372,6 +373,16 @@ class TestDigestEmailMessages(ZulipTestCase):
user = arg[0][0]
self.assertNotEqual(user.id, bot.id)
@mock.patch('zerver.lib.digest.timezone_now')
def test_new_stream_link(self, mock_django_timezone: mock.MagicMock) -> None:
cutoff = datetime.datetime(year=2017, month=11, day=1)
mock_django_timezone.return_value = datetime.datetime(year=2017, month=11, day=5)
cordelia = self.example_user('cordelia')
create_stream_if_needed(cordelia.realm, 'New stream')
new_stream = gather_new_streams(cordelia, cutoff)[1]
expected_html = "<a href='http://zulip.testserver/#narrow/stream/New.20stream'>New stream</a>"
self.assertIn(expected_html, new_stream['html'])
class TestReplyExtraction(ZulipTestCase):
def test_reply_is_extracted_from_plain(self) -> None: