Skip to content

Commit

Permalink
Merge pull request #8697 from cfpb/tccp/protect-situations
Browse files Browse the repository at this point in the history
Return an empty list for tccp situations when invalid data gets cleaned
  • Loading branch information
wpears authored Dec 19, 2024
2 parents 8d13cc9 + 6dafc58 commit 9a67f10
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions cfgov/tccp/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ def test_no_querystring_filters_by_good_tier(self):
self.assertContains(response, "Consumer Financial Protection Bureau")
self.assertContains(response, "There are no results for your search.")

def test_invalid_situations(self):
response = self.make_request("?situations=fake+and+bad")
self.assertContains(response, "There are no results for your search.")

def test_htmx_includes_only_results(self):
response = self.make_request(**{"HTTP_HX-Request": "true"})
self.assertNotContains(
Expand Down
2 changes: 1 addition & 1 deletion cfgov/tccp/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def list(self, request, *args, **kwargs):
# If we're rendering HTML, we need to augment the response context.
if render_format == "html":
form = filter_backend.used_filterset.form
situations = form.cleaned_data["situations"]
situations = form.cleaned_data.get("situations", [])

purchase_apr_rating_ranges = self.get_purchase_apr_rating_ranges(
cards
Expand Down

0 comments on commit 9a67f10

Please sign in to comment.