Skip to content

Commit

Permalink
Merge pull request #880 from DemocracyClub/hotfix/remove-voters-url
Browse files Browse the repository at this point in the history
Fix redirects for /voters and /data
  • Loading branch information
symroe authored Oct 25, 2024
2 parents ea8575c + d1ab0ef commit 747bfb6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
19 changes: 19 additions & 0 deletions democracy_club/apps/core/tests/test_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,25 @@ def test_html_valid(self, client, subtests, urls):
_, errors = validate_html(client, url)
assert errors == ""

@pytest.fixture
def redirected_urls(self):
return [
"/voters/",
"/data/",
"/mailing_list/",
"/impact/",
"/data_apis/index/",
"/about/impact/",
"/about/support-us/",
]

@pytest.mark.django_db
def test_redirected_urls(self, client, redirected_urls):
"""test redirected urls return a 301 or 302 status code"""
for redirect in redirected_urls:
status_code = client.get(redirect).status_code
assert status_code == 301 or status_code == 302

@pytest.mark.django_db
def test_page_title(self, client, urls):
"""test every page has a page title in the
Expand Down
15 changes: 3 additions & 12 deletions democracy_club/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,6 @@ def trigger_error(request):
),
name="voting_information_api",
),
path(
"voters/",
TemplateView.as_view(template_name="for_voters.html"),
name="voters",
),
path("thanks/", TemplateView.as_view(template_name="thanks.html")),
path(
"thanks/finished/",
Expand Down Expand Up @@ -127,11 +122,7 @@ def trigger_error(request):
url_redirects = (
path(
"data/",
RedirectView.as_view(url=reverse_lazy("projects")),
),
path(
"donate/",
RedirectView.as_view(url=reverse_lazy("funding")),
RedirectView.as_view(url=reverse_lazy("projects:home")),
),
path(
"support-us/",
Expand All @@ -147,7 +138,7 @@ def trigger_error(request):
),
path(
"data_apis/index/",
RedirectView.as_view(url=reverse_lazy("voter_information_api")),
RedirectView.as_view(url=reverse_lazy("voting_information_api")),
),
path(
"impact/",
Expand All @@ -161,7 +152,7 @@ def trigger_error(request):
),
path(
"voters/",
RedirectView.as_view(url=reverse_lazy("projects")),
RedirectView.as_view(url=reverse_lazy("projects:home")),
),
)

Expand Down

0 comments on commit 747bfb6

Please sign in to comment.