[WHIT-3125] Filter by latest edition of document#11203
Open
Conversation
ryanb-gds
reviewed
Mar 4, 2026
Contributor
ryanb-gds
left a comment
There was a problem hiding this comment.
Just wanna check something but pretty sure this'll solve the problem 🙌
TonyGDS
reviewed
Mar 4, 2026
a0559e3 to
83060ea
Compare
83060ea to
3be5c0a
Compare
fdd887e to
43aa8e3
Compare
43aa8e3 to
a1b8eb5
Compare
ChrisBAshton
requested changes
Mar 11, 2026
Comment on lines
+10
to
+16
| def topical_event_documents | ||
| Document | ||
| .joins(latest_edition: :translations) | ||
| .where(editions: { configurable_document_type: "topical_event" }) | ||
| .preload(latest_edition: :translations) | ||
| .order("edition_translations.title") | ||
| end |
Contributor
There was a problem hiding this comment.
This is a bit misleading for a test. All we're doing is writing some code in this test file, and testing that code - there's no guarantee we're running the same code inside app/views/admin/editions/_topical_event_fields.html.erb.
The correct way to do this would be to move the code from the view, into a helper (or as a scope/helper method on the Edition::TopicalEvents concern) so that we can write tests against the actual code that is being used.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ISSUE
Creating a new edition of an existing config-driven topical event causes an additional entry to appear in the associations dropdown.
BEFORE
AFTER
The 'first test event' example is the second edition of that document, the 'other topical event' is another document
THIS PR
We should only display one option. This is a code change to filter out all but the latest edition of a document.
Jira