template context: Give better names to the URLs for the API.

The "subdomain" label is redundant, to the extent it's even
accurate -- this is really just the URL we want to display,
which may or may not involve a subdomain.  Similarly "external".

The former `external_api_path_subdomain` was never a path -- it's a
host, followed by a path, which together form a scheme-relative URL.
I'm not quite convinced that value is actually the right thing in
2 of the 3 places we use it, but fixing that can start by giving an
accurate name to the thing we have.
This commit is contained in:
Greg Price
2017-10-30 14:04:15 -07:00
parent 271a9f0da7
commit eb55a3a1ba
26 changed files with 53 additions and 54 deletions

View File

@@ -119,8 +119,8 @@ class IntegrationTest(TestCase):
# type: () -> None
context = dict() # type: Dict[str, Any]
add_api_uri_context(context, HostRequestMock())
self.assertEqual(context["external_api_path_subdomain"], "testserver/api")
self.assertEqual(context["external_api_uri_subdomain"], "http://testserver/api")
self.assertEqual(context["api_url_scheme_relative"], "testserver/api")
self.assertEqual(context["api_url"], "http://testserver/api")
self.assertTrue(context["html_settings_links"])
@override_settings(ROOT_DOMAIN_LANDING_PAGE=True)
@@ -128,8 +128,8 @@ class IntegrationTest(TestCase):
# type: () -> None
context = dict() # type: Dict[str, Any]
add_api_uri_context(context, HostRequestMock())
self.assertEqual(context["external_api_path_subdomain"], "yourZulipDomain.testserver/api")
self.assertEqual(context["external_api_uri_subdomain"], "http://yourZulipDomain.testserver/api")
self.assertEqual(context["api_url_scheme_relative"], "yourZulipDomain.testserver/api")
self.assertEqual(context["api_url"], "http://yourZulipDomain.testserver/api")
self.assertFalse(context["html_settings_links"])
def test_api_url_view_subdomains_full(self):
@@ -137,8 +137,8 @@ class IntegrationTest(TestCase):
context = dict() # type: Dict[str, Any]
request = HostRequestMock(host="mysubdomain.testserver")
add_api_uri_context(context, request)
self.assertEqual(context["external_api_path_subdomain"], "mysubdomain.testserver/api")
self.assertEqual(context["external_api_uri_subdomain"], "http://mysubdomain.testserver/api")
self.assertEqual(context["api_url_scheme_relative"], "mysubdomain.testserver/api")
self.assertEqual(context["api_url"], "http://mysubdomain.testserver/api")
self.assertTrue(context["html_settings_links"])
def test_integration_view_html_settings_links(self):