Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor contents list logic #3366

Merged
merged 3 commits into from
Oct 15, 2024
Merged

Refactor contents list logic #3366

merged 3 commits into from
Oct 15, 2024

Conversation

hannako
Copy link
Contributor

@hannako hannako commented Oct 14, 2024

The original implementation could result in the show_contents_list? method returning nil
rather than true or false. Which is unexpected, and has been a barrier
to changing when and where we display contents lists (trello) because of confusing
test failures (#3361).

@govuk-ci govuk-ci temporarily deployed to government-frontend-pr-3366 October 14, 2024 20:02 Inactive
@hannako hannako force-pushed the contents_list_refactor_2 branch from a8932bb to 30a93a2 Compare October 15, 2024 10:22
@govuk-ci govuk-ci temporarily deployed to government-frontend-pr-3366 October 15, 2024 10:22 Inactive
The original implementation could result in the method returning nil
rather than true or false. Which is unexpected, and has been a barrier
to changing when and where we display contents lists because of confusing
test failures.
@hannako hannako force-pushed the contents_list_refactor_2 branch from 30a93a2 to 6dbefab Compare October 15, 2024 10:42
@govuk-ci govuk-ci temporarily deployed to government-frontend-pr-3366 October 15, 2024 10:43 Inactive
@govuk-ci govuk-ci temporarily deployed to government-frontend-pr-3366 October 15, 2024 10:56 Inactive
@hannako hannako force-pushed the contents_list_refactor_2 branch from 9374fc0 to 35e0a8b Compare October 15, 2024 10:58
@govuk-ci govuk-ci temporarily deployed to government-frontend-pr-3366 October 15, 2024 10:58 Inactive
This test is to check that the contents method returns the memoised
@contents when repeatedly called, rather than running line 10
https://github.com/alphagov/government-frontend/blob/6dbefab2ed477a6328f57227494b4561f811f239/app/presenters/content_item/contents_list.rb#L10

The original test checked if the code on line 11 was run, ie the contents_items method.
But the content_items method is called in two places in this module, within both the contents method (which
this test is testing) but also within the show_contents_items? method.This means changes
to the show_contents_items? code unexpectedly breaks this test. This commit reduces the scope
of the test so that unexpected test failures no longer occur.
@hannako hannako force-pushed the contents_list_refactor_2 branch from 35e0a8b to da0f7c1 Compare October 15, 2024 10:59
@govuk-ci govuk-ci temporarily deployed to government-frontend-pr-3366 October 15, 2024 10:59 Inactive
Copy link
Contributor

@CodeSonia CodeSonia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This just reads so much better! 🙌

Copy link
Contributor

@beccapearce beccapearce left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This all looks good! Easier to get than before

@hannako hannako merged commit a4a173a into main Oct 15, 2024
11 checks passed
@hannako hannako deleted the contents_list_refactor_2 branch October 15, 2024 13:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants