tmp#11000
Closed
ChrisBAshton wants to merge 6 commits into
Closed
Conversation
(Temporarily enabled to test social media links. Can always disable it later).
It makes more sense to me that our payload methods for 'primitive' data types appear first - string, integer, etc - and that then we have generic non-primitive types - govspeak, rfc3339_date, etc and finally, we have highly specific specialised types like lead_image (and soon, social_media_links).
To support the introduction of schema-defined array content blocks, block_content is now normalised through StandardEdition::BlockContent before being persisted.
Previously, block_content= merged and saved the raw params hash, meaning schema-aware coercion (dates, arrays, etc.) and cleanup logic only ran during validation, not persistence. This caused array-shaped params to be stored inconsistently and allowed form-specific concerns (such as _destroy) to leak into saved data.
This change ensures:
Array-typed attributes are normalised according to the schema
Hash-shaped params ({ "0" => {...}, "1" => {...} }) are converted to arrays
_destroy entries are filtered out in line with Rails nested-attribute semantics
Persisted block_content reflects the schema-defined structure
As part of this, we intentionally now persist the full schema shape for block_content. All attributes defined in the schema are present in saved data, even when their value is nil. This makes the stored representation consistent and predictable, and aligns persistence with validation and presentation logic.
Tests have been updated accordingly: editions without images now have an explicit image: nil entry in block_content, rather than the key being absent.
By persisting BlockContent#to_h, validation and storage now share a single, schema-driven source of truth, enabling richer structured content blocks while keeping model behaviour consistent and explicit.
Note that we've had to add several missing `ConfigurableDocumentType.setup_test_types`
calls, because now `block_content=` now always calls `type_instance.schema`,
which means it must call:
`ConfigurableDocumentType.find(configurable_document_type)`
TODO: - Add tests - Support for translations - Clarify the publishing API payload mapping.
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.
No description provided.