Repository: mdn/kuma

Issue:
T - Add 301 redirect to Subscriptions Management page 
`/payments/recurring/management` is moving to `/payments/management`, therefore we need to add 301 redirect in kuma/payments/urls.py

See https://github.com/mdn/kuma/issues/6703#issuecomment-614246571 for context 


Discussion:
@mindy I think we've got this the wrong way around. In terms of blocking/blocked by. 
What I think you should do is create a brand new entry in `payments/urls.py` and kinda prentend the old one doesn't exist. 
Even the Django view function name is poor (`recurring_payment_management`). 

So, once you've created a new line in `urls.py` and a new Django view function that wraps the React SPA stuff, then I'll work on *this* issue to make sure the redirect works as expected. 
Bha!! I'm an idiot. I misread the blockers. I *thought* this issue was blocking [*your* issue](https://github.com/mdn/kuma/issues/6896). 

But still, I think it would be nice, for me, to work on this if there's a new URL I can redirect to so I'll still keep the new tracking blockage I added. 

Resolving patch:
diff --git a/kuma/payments/urls.py b/kuma/payments/urls.py
--- a/kuma/payments/urls.py
+++ b/kuma/payments/urls.py
@@ -1,10 +1,17 @@
 from django.urls import path
+from django.views.generic import RedirectView
 
 from . import views
 
 lang_urlpatterns = [
     path("terms/", views.payment_terms, name="payment_terms"),
     path("thank-you/", views.thank_you, name="thank_you"),
-    path("management/", views.payment_management, name="payment_management",),
+    path(
+        # This is the old URL we had for a while
+        "recurring/management/",
+        RedirectView.as_view(pattern_name="payment_management", permanent=True),
+        name="recurring_payment_management",
+    ),
+    path("management/", views.payment_management, name="payment_management"),
     path("", views.index, name="payments_index"),
 ]
diff --git a/kuma/payments/views.py b/kuma/payments/views.py
--- a/kuma/payments/views.py
+++ b/kuma/payments/views.py
@@ -13,8 +13,6 @@
 @never_cache
 def index(request):
     highest_subscriber_number = User.get_highest_subscriber_number()
-    # TODO: This is never unit tested because our tests never test SSR rendering.
-    # See https://github.com/mdn/kuma/issues/6797
     context = {"next_subscriber_number": highest_subscriber_number + 1}
     return render(request, "payments/index.html", context)
 


Test patch:
diff --git a/kuma/payments/tests/test_views.py b/kuma/payments/tests/test_views.py
--- a/kuma/payments/tests/test_views.py
+++ b/kuma/payments/tests/test_views.py
@@ -1,19 +1,11 @@
-from dataclasses import dataclass
-
 import pytest
-from django.conf import settings
 from pyquery import PyQuery as pq
 
 from kuma.core.urlresolvers import reverse
 
 
-@dataclass
-class MockSubscription:
-    id: str = "sub_123456789"
-
-
 @pytest.mark.django_db
-def test_payments_index(client):
+def test_payments_index(client, settings):
     """Viewing the payments index page doesn't require you to be logged in.
     Payments page shows support email and header."""
     response = client.get(reverse("payments_index"))
@@ -35,3 +27,11 @@ def test_payments_url_fixes(client):
     assert response["location"] == url
     response = client.get(url + "xxxx", follow=False)
     assert response.status_code == 404
+
+
+def test_payments_recurring_management_redirect(client):
+    """That old redirect used to be something we exposed, so it's important to
+    assert that we took care of redirecting it to its new location."""
+    response = client.get(reverse("recurring_payment_management"), follow=False)
+    assert response.status_code == 301
+    assert response["location"] == reverse("payment_management")