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 class="bottom">
<div class="text-content">
{% if realm_plan_type == 0 %}
{% if realm_plan_type <= 1 %}
<div class="pricing-details">
Free
</div>

View File

@ -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"])

View File

@ -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("/"),

View File

@ -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")