From ab2dd4613f94525b75576a2bc603003bbf85aba7 Mon Sep 17 00:00:00 2001 From: Matthew Piatetsky Date: Tue, 1 Aug 2017 13:20:14 -0400 Subject: [PATCH] Removed waffle flag and added test for utm params on redirect LEARNER-2016 --- lms/djangoapps/verify_student/tests/test_views.py | 10 ++++++++-- lms/djangoapps/verify_student/views.py | 3 +-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/lms/djangoapps/verify_student/tests/test_views.py b/lms/djangoapps/verify_student/tests/test_views.py index bb7f67ad61..08ccb815f2 100644 --- a/lms/djangoapps/verify_student/tests/test_views.py +++ b/lms/djangoapps/verify_student/tests/test_views.py @@ -35,6 +35,7 @@ from course_modes.models import CourseMode from course_modes.tests.factories import CourseModeFactory from lms.djangoapps.verify_student.models import SoftwareSecurePhotoVerification, VerificationDeadline from lms.djangoapps.verify_student.views import PayAndVerifyView, checkout_with_ecommerce_service, render_to_response +from commerce.utils import EcommerceService from openedx.core.djangoapps.embargo.test_utils import restrict_course from openedx.core.djangoapps.theming.tests.test_util import with_comprehensive_theme from openedx.core.djangoapps.user_api.accounts.api import get_account_settings @@ -141,12 +142,17 @@ class TestPayAndVerifyView(UrlResetMixin, ModuleStoreTestCase, XssTestMixin): ) configuration = CommerceConfiguration.objects.create(checkout_on_ecommerce_service=True) checkout_page = configuration.MULTIPLE_ITEMS_BASKET_PAGE_URL + checkout_page += "?utm_source=test" httpretty.register_uri(httpretty.GET, "{}{}".format(TEST_PUBLIC_URL_ROOT, checkout_page)) course = self._create_course('verified', sku=sku) self._enroll(course.id) - response = self._get_page('verify_student_start_flow', course.id, expected_status_code=302) - expected_page = '{}{}?sku={}'.format(TEST_PUBLIC_URL_ROOT, checkout_page, sku) + + # Verify that utm params are included in the url used for redirect + url_with_utm = 'http://www.example.com/basket/add/?utm_source=test&sku=TESTSKU' + with mock.patch.object(EcommerceService, 'get_checkout_page_url', return_value=url_with_utm): + response = self._get_page('verify_student_start_flow', course.id, expected_status_code=302) + expected_page = '{}{}&sku={}'.format(TEST_PUBLIC_URL_ROOT, checkout_page, sku) self.assertRedirects(response, expected_page, fetch_redirect_response=False) @ddt.data( diff --git a/lms/djangoapps/verify_student/views.py b/lms/djangoapps/verify_student/views.py index ea2819ba31..5c305873b1 100644 --- a/lms/djangoapps/verify_student/views.py +++ b/lms/djangoapps/verify_student/views.py @@ -520,8 +520,7 @@ class PayAndVerifyView(View): # Redirect if necessary, otherwise implicitly return None if url is not None: - if waffle.switch_is_active('add-utm-params'): - url = self.add_utm_params_to_url(url) + url = self.add_utm_params_to_url(url) return redirect(url) def _get_paid_mode(self, course_key):