Ghost/ghost/core/test/unit
Simon Backx 69d07c892c
Fixed getLazyRelation returning new model for optional relations (#16411)
no issue

When using `getLazyRelation` on an optional relation that is not set, it
will return a newly created model instead of a model from the database.
- Adds a new require option to `getLazyRelation`, that throws an error
if the relation is not set (off by default to match existing use cases)
- This caused a bug (not visible because we always pass a newsletter id)
in email previews, where when the newsletter id was not explicitly set,
it would use `newsletter = (await post.getLazyRelation('newsletter')) ??
(await this.models.Newsletter.getDefaultNewsletter());`, which always
returned the first one, and could return a newly initiated newsletter
with all properties set to undefined.
- Some page snapshots are altered by this, because the usage of
`getLazyRelation` on a post no longer sets the email relation to some
new model.
2023-03-14 10:58:58 +01:00
..
api/canary Removed all unused variables from test files 2023-03-10 14:29:55 +01:00
frontend Removed all unused variables from test files 2023-03-10 14:29:55 +01:00
server Fixed getLazyRelation returning new model for optional relations (#16411) 2023-03-14 10:58:58 +01:00
shared Removed all unused variables from test files 2023-03-10 14:29:55 +01:00