diff --git a/templates/zerver/plans.html b/templates/zerver/plans.html index ef5954a269..18966df194 100644 --- a/templates/zerver/plans.html +++ b/templates/zerver/plans.html @@ -38,7 +38,7 @@
- {% if realm_plan_type == 0 %} + {% if realm_plan_type <= 1 %}
Free
diff --git a/zerver/tests/test_docs.py b/zerver/tests/test_docs.py index 01712a4bd8..c7328010df 100644 --- a/zerver/tests/test_docs.py +++ b/zerver/tests/test_docs.py @@ -472,16 +472,23 @@ class PlansPageTest(ZulipTestCase): realm = get_realm("zulip") realm.plan_type = Realm.SELF_HOSTED realm.save(update_fields=["plan_type"]) - result = self.client_get("/plans/", subdomain="zulip") - self.assertEqual(result.status_code, 302) - self.assertEqual(result["Location"], "https://zulipchat.com/plans") - self.login(self.example_email("iago")) + with self.settings(PRODUCTION=True): + result = self.client_get("/plans/", subdomain="zulip") + self.assertEqual(result.status_code, 302) + self.assertEqual(result["Location"], "https://zulipchat.com/plans") - # SELF_HOSTED should hide the local plans page, even if logged in + self.login(self.example_email("iago")) + + # SELF_HOSTED should hide the local plans page, even if logged in + result = self.client_get("/plans/", subdomain="zulip") + self.assertEqual(result.status_code, 302) + self.assertEqual(result["Location"], "https://zulipchat.com/plans") + + # But in the development environment, it renders a page result = self.client_get("/plans/", subdomain="zulip") - self.assertEqual(result.status_code, 302) - self.assertEqual(result["Location"], "https://zulipchat.com/plans") + self.assert_in_success_response([sign_up_now, buy_standard], result) + self.assert_not_in_success_response([current_plan], result) realm.plan_type = Realm.LIMITED realm.save(update_fields=["plan_type"]) diff --git a/zerver/tests/test_templates.py b/zerver/tests/test_templates.py index ee0eeeab81..4968f91296 100644 --- a/zerver/tests/test_templates.py +++ b/zerver/tests/test_templates.py @@ -15,6 +15,7 @@ from zerver.lib.test_classes import ( ZulipTestCase, ) from zerver.lib.test_runner import slow +from zerver.models import Realm class get_form_value: @@ -177,6 +178,7 @@ class TemplateTestCase(ZulipTestCase): "login_time": "9:33am NewYork, NewYork", }, api_uri_context={}, + realm_plan_type=Realm.LIMITED, cloud_annual_price=80, seat_count=8, request=RequestFactory().get("/"), diff --git a/zerver/views/home.py b/zerver/views/home.py index 40527a64e5..356c2869f2 100644 --- a/zerver/views/home.py +++ b/zerver/views/home.py @@ -321,7 +321,7 @@ def plans_view(request: HttpRequest) -> HttpResponse: realm_plan_type = 0 if realm is not None: realm_plan_type = realm.plan_type - if realm.plan_type == Realm.SELF_HOSTED: + if realm.plan_type == Realm.SELF_HOSTED and settings.PRODUCTION: return HttpResponseRedirect('https://zulipchat.com/plans') if not request.user.is_authenticated(): return redirect_to_login(next="plans")