Construct absolute URLs with the correct protocol and port
This commit is contained in:
parent
3aefbb548e
commit
c42db40a63
14 changed files with 55 additions and 73 deletions
|
@ -8,7 +8,7 @@ from django.test.client import RequestFactory
|
|||
import responses
|
||||
|
||||
from bookwyrm import models, views
|
||||
from bookwyrm.settings import USER_AGENT, DOMAIN
|
||||
from bookwyrm.settings import USER_AGENT, BASE_URL
|
||||
|
||||
|
||||
@patch("bookwyrm.activitystreams.add_status_task.delay")
|
||||
|
@ -288,13 +288,13 @@ class ViewsHelpers(TestCase): # pylint: disable=too-many-public-methods
|
|||
def test_redirect_to_referer_valid_domain(self, *_):
|
||||
"""redirect to within the app"""
|
||||
request = self.factory.get("/path")
|
||||
request.META = {"HTTP_REFERER": f"https://{DOMAIN}/and/a/path"}
|
||||
request.META = {"HTTP_REFERER": f"{BASE_URL}/and/a/path"}
|
||||
result = views.helpers.redirect_to_referer(request)
|
||||
self.assertEqual(result.url, f"https://{DOMAIN}/and/a/path")
|
||||
self.assertEqual(result.url, f"{BASE_URL}/and/a/path")
|
||||
|
||||
def test_redirect_to_referer_with_get_args(self, *_):
|
||||
"""if the path has get params (like sort) they are preserved"""
|
||||
request = self.factory.get("/path")
|
||||
request.META = {"HTTP_REFERER": f"https://{DOMAIN}/and/a/path?sort=hello"}
|
||||
request.META = {"HTTP_REFERER": f"{BASE_URL}/and/a/path?sort=hello"}
|
||||
result = views.helpers.redirect_to_referer(request)
|
||||
self.assertEqual(result.url, f"https://{DOMAIN}/and/a/path?sort=hello")
|
||||
self.assertEqual(result.url, f"{BASE_URL}/and/a/path?sort=hello")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue