plans: Make usable in the development environment for testing.

This commit is contained in:
Tim Abbott 2019-07-22 17:33:45 -07:00
parent 8c55e27d1e
commit 47d80977ac
4 changed files with 18 additions and 9 deletions

View File

@ -38,7 +38,7 @@
</div> </div>
<div class="bottom"> <div class="bottom">
<div class="text-content"> <div class="text-content">
{% if realm_plan_type == 0 %} {% if realm_plan_type <= 1 %}
<div class="pricing-details"> <div class="pricing-details">
Free Free
</div> </div>

View File

@ -472,6 +472,8 @@ class PlansPageTest(ZulipTestCase):
realm = get_realm("zulip") realm = get_realm("zulip")
realm.plan_type = Realm.SELF_HOSTED realm.plan_type = Realm.SELF_HOSTED
realm.save(update_fields=["plan_type"]) realm.save(update_fields=["plan_type"])
with self.settings(PRODUCTION=True):
result = self.client_get("/plans/", subdomain="zulip") result = self.client_get("/plans/", subdomain="zulip")
self.assertEqual(result.status_code, 302) self.assertEqual(result.status_code, 302)
self.assertEqual(result["Location"], "https://zulipchat.com/plans") self.assertEqual(result["Location"], "https://zulipchat.com/plans")
@ -483,6 +485,11 @@ class PlansPageTest(ZulipTestCase):
self.assertEqual(result.status_code, 302) self.assertEqual(result.status_code, 302)
self.assertEqual(result["Location"], "https://zulipchat.com/plans") 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.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.plan_type = Realm.LIMITED
realm.save(update_fields=["plan_type"]) realm.save(update_fields=["plan_type"])
result = self.client_get("/plans/", subdomain="zulip") result = self.client_get("/plans/", subdomain="zulip")

View File

@ -15,6 +15,7 @@ from zerver.lib.test_classes import (
ZulipTestCase, ZulipTestCase,
) )
from zerver.lib.test_runner import slow from zerver.lib.test_runner import slow
from zerver.models import Realm
class get_form_value: class get_form_value:
@ -177,6 +178,7 @@ class TemplateTestCase(ZulipTestCase):
"login_time": "9:33am NewYork, NewYork", "login_time": "9:33am NewYork, NewYork",
}, },
api_uri_context={}, api_uri_context={},
realm_plan_type=Realm.LIMITED,
cloud_annual_price=80, cloud_annual_price=80,
seat_count=8, seat_count=8,
request=RequestFactory().get("/"), request=RequestFactory().get("/"),

View File

@ -321,7 +321,7 @@ def plans_view(request: HttpRequest) -> HttpResponse:
realm_plan_type = 0 realm_plan_type = 0
if realm is not None: if realm is not None:
realm_plan_type = realm.plan_type 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') return HttpResponseRedirect('https://zulipchat.com/plans')
if not request.user.is_authenticated(): if not request.user.is_authenticated():
return redirect_to_login(next="plans") return redirect_to_login(next="plans")