Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

support: Correctly show Unspecified org type at /activity/support.

Mateusz Mandera30c26b9510cb
diff --git a/analytics/tests/test_support_views.py b/analytics/tests/test_support_views.py
index a0a542674b8..a76872e2c4f 100644
--- a/analytics/tests/test_support_views.py
+++ b/analytics/tests/test_support_views.py
@@ -8,7 +8,11 @@ from django.utils.timezone import now as timezone_now
from corporate.lib.stripe import add_months, update_sponsorship_status
from corporate.models import Customer, CustomerPlan, LicenseLedger, get_customer_by_realm
from zerver.actions.invites import do_create_multiuse_invite_link
-from zerver.actions.realm_settings import do_send_realm_reactivation_email, do_set_realm_property
+from zerver.actions.realm_settings import (
+ do_change_realm_org_type,
+ do_send_realm_reactivation_email,
+ do_set_realm_property,
+)
from zerver.lib.test_classes import ZulipTestCase
from zerver.lib.test_helpers import reset_emails_in_zulip_realm
from zerver.models import (
@@ -337,6 +341,28 @@ class TestSupportEndpoint(ZulipTestCase):
self.assertEqual(get_org_type_display_name(Realm.ORG_TYPES["business"]["id"]), "Business")
self.assertEqual(get_org_type_display_name(883), "")
+ def test_unspecified_org_type_correctly_displayed(self) -> None:
+ """
+ Unspecified org type is special in that it is marked to not be shown
+ on the registration page (because organitions are not meant to be able to choose it),
+ but should be correctly shown at the /support endpoint.
+ """
+ realm = get_realm("zulip")
+
+ do_change_realm_org_type(realm, 0, acting_user=None)
+ self.assertEqual(realm.org_type, 0)
+
+ self.login("iago")
+
+ result = self.client_get("/activity/support", {"q": "zulip"}, subdomain="zulip")
+ self.assert_in_success_response(
+ [
+ f'<input type="hidden" name="realm_id" value="{realm.id}"',
+ '<option value="0" selected>',
+ ],
+ result,
+ )
+
@mock.patch("analytics.views.support.update_billing_method_of_current_plan")
def test_change_billing_method(self, m: mock.Mock) -> None:
cordelia = self.example_user("cordelia")
diff --git a/templates/analytics/realm_details.html b/templates/analytics/realm_details.html
index b73e055821d..88c7872bf6a 100644
--- a/templates/analytics/realm_details.html
+++ b/templates/analytics/realm_details.html
@@ -53,11 +53,9 @@
<input type="hidden" name="realm_id" value="{{ realm.id }}" />
<select name="org_type" id="org_type">
{% for realm_type in sorted_realm_types %}
- {% if not realm_type.hidden %}
<option value="{{ realm_type.id }}" {% if realm.org_type == realm_type.id %}selected{% endif %}>
{{ _(realm_type.name) }}
</option>
- {% endif %}
{% endfor %}
</select>
<button type="submit" class="btn btn-default support-submit-button">Update</button>