Skip to content

Commit

Permalink
Fix for "back to search" always appearing
Browse files Browse the repository at this point in the history
This link was appearing even when there was no search context present
  • Loading branch information
jacksonj04 committed May 24, 2023
1 parent 0d5ee48 commit ed86375
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{% load i18n %}
<div class="judgment-toolbar">
<div class="judgment-toolbar__return-link">
<a href="{{ context.back_link }}">{% translate "judgment.back" %}</a>
</div>
{% if context.back_link %}
<div class="judgment-toolbar__return-link">
<a href="{{ context.back_link }}">{% translate "judgment.back" %}</a>
</div>
{% endif %}
<div class="judgment-toolbar__container">
{% if context.back_link %}{% endif %}
<h1 class="judgment-toolbar__title">
{{ context.judgment_title }}
<br>
Expand Down
13 changes: 13 additions & 0 deletions judgments/tests/test_detail.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,19 @@ def test_published_judgment_response(self, mock_judgment, mock_pdf_size):
self.assertEqual(response.status_code, 200)


class TestJudgmentBackToSearchLink(TestCase):
@patch("judgments.views.detail.get_pdf_size")
@patch("judgments.views.detail.get_published_judgment_by_uri")
def test_no_link_if_no_context(self, mock_judgment, mock_pdf_size):
mock_judgment.return_value = JudgmentFactory.build(is_published=True)
mock_pdf_size.return_value = "1234KB"

response = self.client.get("/test/2023/123")
decoded_response = response.content.decode("utf-8")

assert "Back to search results" not in decoded_response


class TestJudgmentPdfLinkText(TestCase):
@patch("judgments.views.detail.get_pdf_size")
@patch("judgments.views.detail.get_published_judgment_by_uri")
Expand Down

0 comments on commit ed86375

Please sign in to comment.