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

Fix issue with former redirects being unable to be unpublished #1156

Merged
merged 2 commits into from
Sep 28, 2023

Conversation

brucebolt
Copy link
Member

items.redirects can sometimes be nil. Therefore we need to convert it to an array (even if empty) before doing map, else we get an error as nil does not have a map method.

This will resolve an issue in production where we are unable to unpublish former redirects.

Trello card

The `GonePresenter` in Publishing API does not include a value for
`redirects` [1], therefore it will be `nil`.

Our current test for 'gone' content items assumes the value of
`redirects` will be `[]`, which is not true.

This appears to be causing an error when we try to unpublish former
redirects with a 'gone' content item in their place.

Therefore adding a test that reproduces the problem we have seen in
production.

1: https://github.com/alphagov/publishing-api/blob/712b548ee6e75c85a15d808d667678c68e2d3145/app/presenters/gone_presenter.rb#L42-L56
`items.redirects` can sometimes be `nil`. Therefore we need to convert
it to an array (even if empty) before doing `map`, else we get an error
as `nil` does not have a `map` method.

This will resolve an issue in production where we are unable to
unpublish former redirects.
@brucebolt brucebolt marked this pull request as ready for review September 28, 2023 15:15
@brucebolt brucebolt merged commit 7d85096 into main Sep 28, 2023
5 checks passed
@brucebolt brucebolt deleted the fix-gone-unpublish branch September 28, 2023 15:37
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.

2 participants