|
@@ -146,6 +146,10 @@ urlpatterns = [
|
|
|
OrganizationTestEndpoint.as_view(),
|
|
|
name="org-events-endpoint",
|
|
|
),
|
|
|
+ url(
|
|
|
+ r"^api/0/(?P<organization_slug>[^\/]+)/nameless/$",
|
|
|
+ OrganizationTestEndpoint.as_view(),
|
|
|
+ ),
|
|
|
]
|
|
|
|
|
|
|
|
@@ -387,3 +391,22 @@ class End2EndTest(APITestCase):
|
|
|
}
|
|
|
assert "activeorg" in self.client.session
|
|
|
assert self.client.session["activeorg"] == "test"
|
|
|
+
|
|
|
+ def test_with_middleware_and_nameless_view(self):
|
|
|
+ self.create_organization(name="albertos-apples")
|
|
|
+
|
|
|
+ with override_settings(MIDDLEWARE=tuple(self.middleware)):
|
|
|
+ response = self.client.get(
|
|
|
+ "/api/0/some-org/nameless/",
|
|
|
+ HTTP_HOST="albertos-apples.testserver",
|
|
|
+ follow=True,
|
|
|
+ )
|
|
|
+ assert response.status_code == 200
|
|
|
+ assert response.redirect_chain == [("/api/0/albertos-apples/nameless/", 302)]
|
|
|
+ assert response.data == {
|
|
|
+ "organization_slug": "albertos-apples",
|
|
|
+ "subdomain": "albertos-apples",
|
|
|
+ "activeorg": "albertos-apples",
|
|
|
+ }
|
|
|
+ assert "activeorg" in self.client.session
|
|
|
+ assert self.client.session["activeorg"] == "albertos-apples"
|