Commit 5168f61
committed
Fix
```
Failure: StandardEditionTranslationBlockContentConsistencyTest#test_editions_without_images_should_not_have_image_key_in_block_content [test/unit/app/models/standard_edition_translation_block_content_consistency_test.rb:45]: English translation should not have image key. Expected ["field_attribute", "body", "image"] to not include "image". bin/rails test test/unit/app/models/standard_edition_translation_block_content_consistency_test.rb:42
```
This test was failing after the tweak in the previous commit.
Why?
- When we call `BlockContent#assign_attributes`, it iterates every attribute in the schema and calls the setter for it.
- For "image" (type "object"), the code does `public_send("image=", values["image"])`.
- If values["image"] is missing, that's `nil` — and because the
attributes class has `attribute :image`, `to_h` will include
`"image" => nil`, which makes `block_content.keys` include "image".
So we've just had to add a `.compact` to filter out all `nil`s.nil behaviour1 parent d3442bd commit 5168f61
1 file changed
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
94 | | - | |
| 94 | + | |
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
| |||
0 commit comments