diff --git a/common/djangoapps/student/tests/test_email.py b/common/djangoapps/student/tests/test_email.py index 9df658bddb..ba039ffc77 100644 --- a/common/djangoapps/student/tests/test_email.py +++ b/common/djangoapps/student/tests/test_email.py @@ -9,7 +9,7 @@ from django.core import mail from django.core.urlresolvers import reverse from django.db import transaction from django.http import HttpResponse -from django.test import TestCase, TransactionTestCase +from django.test import override_settings, TestCase, TransactionTestCase from django.test.client import RequestFactory from mock import Mock, patch @@ -437,6 +437,25 @@ class EmailChangeConfirmationTests(EmailTestMixin, TransactionTestCase): ) self.assertEquals(0, PendingEmailChange.objects.count()) + @unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', "Test only valid in LMS") + @override_settings(MKTG_URLS={'ROOT': 'https://dummy-root', 'CONTACT': '/help/contact-us'}) + def test_marketing_contact_link(self, _email_user): + context = { + 'site': 'edx.org', + 'old_email': 'old@example.com', + 'new_email': 'new@example.com', + } + + confirm_email_body = render_to_string('emails/confirm_email_change.txt', context) + # With marketing site disabled, should link to the LMS contact static page. + # The http(s) part was omitted keep the test focused. + self.assertIn('://edx.org/contact', confirm_email_body) + + with patch.dict(settings.FEATURES, {'ENABLE_MKTG_SITE': True}): + # Marketing site enabled, should link to the marketing site contact page. + confirm_email_body = render_to_string('emails/confirm_email_change.txt', context) + self.assertIn('https://dummy-root/help/contact-us', confirm_email_body) + @patch('student.views.PendingEmailChange.objects.get', Mock(side_effect=TestException)) def test_always_rollback(self, _email_user): connection = transaction.get_connection() diff --git a/common/test/test_sites/test_site/templates/emails/confirm_email_change.txt b/common/test/test_sites/test_site/templates/emails/confirm_email_change.txt index 406175d1cd..8886280c30 100644 --- a/common/test/test_sites/test_site/templates/emails/confirm_email_change.txt +++ b/common/test/test_sites/test_site/templates/emails/confirm_email_change.txt @@ -1,14 +1,16 @@ <%! from django.core.urlresolvers import reverse %> +<%! from django.conf import settings %> +<%! from edxmako.shortcuts import render_to_string, marketing_link %> This is to confirm that you changed the e-mail associated with Open edX from ${old_email} to ${new_email}. If you did not make this request, please contact us immediately. Contact information is listed at: -% if is_secure: - https://${ site }${reverse('contact')} +% if settings.FEATURES['ENABLE_MKTG_SITE']: + ${marketing_link('CONTACT')} % else: - http://${ site }${reverse('contact')} + http://${ site }${reverse('contact')} % endif We keep a log of old e-mails, so if this request was unintentional, we diff --git a/lms/templates/emails/confirm_email_change.txt b/lms/templates/emails/confirm_email_change.txt index 45a7a8195e..2890c54f48 100644 --- a/lms/templates/emails/confirm_email_change.txt +++ b/lms/templates/emails/confirm_email_change.txt @@ -1,6 +1,7 @@ <%! from django.core.urlresolvers import reverse %> <%! from django.utils.translation import ugettext as _ %> <%! from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers %> +<%! from edxmako.shortcuts import render_to_string, marketing_link %> ${_("This is to confirm that you changed the e-mail associated with " "{platform_name} from {old_email} to {new_email}. If you " "did not make this request, please contact us immediately. Contact " @@ -11,10 +12,14 @@ ${_("This is to confirm that you changed the e-mail associated with " ) } -% if is_secure: - https://${ site }${reverse('contact')} +% if settings.FEATURES['ENABLE_MKTG_SITE']: + ${marketing_link('CONTACT')} % else: - http://${ site }${reverse('contact')} + % if is_secure: + https://${ site }${reverse('contact')} + % else: + http://${ site }${reverse('contact')} + % endif % endif ${_("We keep a log of old e-mails, so if this request was unintentional, we can investigate.")}