Ghost/ghost/core/test/unit/server/models
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
..
base Fixed getLazyRelation returning new model for optional relations (#16411) 2023-03-14 10:58:58 +01:00
api-key.test.js Removed all unused variables from test files 2023-03-10 14:29:55 +01:00
comment.test.js Converted Ghost repo into a monorepo 2022-07-20 16:41:05 +02:00
custom-theme-setting.test.js Converted Ghost repo into a monorepo 2022-07-20 16:41:05 +02:00
email-spam-complaint-event.test.js Added email_spam_complaint_events table and model 2022-11-29 18:13:12 +07:00
integration.test.js Removed all unused variables from test files 2023-03-10 14:29:55 +01:00
invite.test.js Removed bluebird dependency from unit tests in core (#16096) 2023-01-23 11:23:48 +00:00
member-click-event.test.js Added post_id filter and total to activity feed API (#15650) 2022-10-18 15:52:04 +02:00
member-created-event.test.js Added ENUM validation for member/subscription created events (#15312) 2022-08-25 15:39:37 +02:00
member-feedback.test.js Added members_feedback table (#15581) 2022-10-11 13:21:31 +02:00
member-paid-subscription-event.test.js Added post_id filter and total to activity feed API (#15650) 2022-10-18 15:52:04 +02:00
member-subscribe-event.test.js Added ENUM validation for member/subscription created events (#15312) 2022-08-25 15:39:37 +02:00
member.test.js Fixed configUtils and adapter cache issues in E2E tests (#16167) 2023-01-30 14:06:20 +01:00
milestone.test.js Added BookshelfMilestoneRepository implementation (#16305) 2023-02-22 15:53:29 +02:00
newsletter.test.js Removed all unused variables from test files 2023-03-10 14:29:55 +01:00
permission.test.js Removed all unused variables from test files 2023-03-10 14:29:55 +01:00
post.test.js Added post sentiment (#15592) 2022-10-11 17:52:14 +02:00
session.test.js Converted Ghost repo into a monorepo 2022-07-20 16:41:05 +02:00
settings.test.js Removed all unused variables from test files 2023-03-10 14:29:55 +01:00
single-use-token.test.js 🐛 Fixed SingleUseTokens being cleared on boot (#15999) 2023-01-04 09:49:39 +01:00
stripe-customer-subscription.test.js Removed all unused variables from test files 2023-03-10 14:29:55 +01:00
subscription-created-event.test.js Added ENUM validation for member/subscription created events (#15312) 2022-08-25 15:39:37 +02:00
suppression.test.js Added suppressions table and model 2022-11-29 18:12:24 +07:00
tag.test.js Removed all unused variables from test files 2023-03-10 14:29:55 +01:00
user.test.js Removed all unused variables from test files 2023-03-10 14:29:55 +01:00