You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The previous code did not work at all for policy groups, and consultation and call for evidence responses, which are not editions.
Since the access limitation restrictions should already kick in before this asset payload is constructed, there is no reason to check for visibility at this level. We have removed the calls to `visible_edition` in favour of just using the `significant_attachable`. This should correctly return either visible attachables or the draft attachable. This works correctly for all attachable types, including responses and policy groups.
In order to correctly construct the draft or live attachable URL, we need to determine if it is in draft state. Policy groups are immediately published, so this does not apply to them. For responses, we want to send the parent edition's URL, so we can check the parent state. I have made the `parent_attachable` method public, so we can identify response-like classes - this method is only defined on `ConsultationResponse` and `CallForEvidenceResponse` at the moment.
For context, the method was previously never called with a user argument to check the visibility for. The line `visible_edition.blank? && draft_edition` was particularly confusing, since the visible edition should also return the draft_edition, if called with a user. It also invalidated the whole point of ever checking for visibility, when falling back to the draft_edition anyway.
# Tests would still pass without this line which is executed as part of the EditionDeleter, but wanted to make sure it doesn't have anything to do with the attachment being deleted.
475
+
# This indicates we could write these as controller or other integration tests.
# Tests would still pass without this line which is executed as part of the EditionDeleter, but wanted to make sure it doesn't have anything to do with the attachment being deleted.
520
+
# This indicates we could write these as controller or other integration tests.
0 commit comments