Skip to content

tmp#11000

Closed
ChrisBAshton wants to merge 6 commits into
mainfrom
add_social_media_support_content_block_approach--bak
Closed

tmp#11000
ChrisBAshton wants to merge 6 commits into
mainfrom
add_social_media_support_content_block_approach--bak

Conversation

@ChrisBAshton
Copy link
Copy Markdown
Contributor

No description provided.

ChrisBAshton and others added 6 commits January 14, 2026 13:41
(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.
@ChrisBAshton ChrisBAshton deleted the add_social_media_support_content_block_approach--bak branch January 14, 2026 15:21
@ChrisBAshton ChrisBAshton restored the add_social_media_support_content_block_approach--bak branch January 14, 2026 15:31
@ChrisBAshton ChrisBAshton reopened this Jan 14, 2026
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