Ghost/test/unit/models
Kevin Ansfield 426cbeec0f
🐛 Fixed performance regression introduced in 4.1.0 (#12807)
closes https://github.com/TryGhost/Ghost/issues/12791
closes https://github.com/TryGhost/Team/issues/566

https://github.com/TryGhost/Ghost/pull/12787 introduced a significant performance regression due to a misunderstanding of when Bookshelf calls `.format()` ([related upstream issue](https://github.com/bookshelf/bookshelf/issues/668)). We expected `.format()` to only be called on save but it's also called when Bookshelf performs fetching and eager loading which happens frequently. `.format()` can be a heavy method as it needs to parse and serialize html and markdown so it should be performed as infrequently as possible.

- override `sync()` in the base model so we can call our own `.formatOnWrite()` method to transform attributes on `update` and `insert` operations
  - this was the only feasible location in Bookshelf I could find that is low enough level to not require modifying model instance attributes
  - gives models the option to perform heavy transform operations only when writing to the database compared to the usual `.format()` method that is also called on fetch in many situations
2021-03-23 09:11:24 +00:00
..
base Fixed "no-shadow" eslint warning in tests 2020-10-19 17:45:26 +13:00
plugins Added support for ordering Post API resources by fields coming form posts_meta table (#12226) 2020-09-24 13:32:40 +12:00
api-key_spec.js Move tests from core to root (#11700) 2020-03-30 16:26:47 +01:00
integration_spec.js Move tests from core to root (#11700) 2020-03-30 16:26:47 +01:00
invite_spec.js Refactored tests to destructure common lib import (#11838) 2020-05-25 09:49:38 +01:00
member_spec.js Fixed "no-shadow" eslint warning in tests 2020-10-19 17:45:26 +13:00
permission_spec.js Updated var declarations to const/let and no lists 2020-04-29 16:51:13 +01:00
post_spec.js 🐛 Fixed __GHOST_URL__ appearing in sitemaps (#12787) 2021-03-18 17:16:37 +00:00
session_spec.js Move tests from core to root (#11700) 2020-03-30 16:26:47 +01:00
settings_spec.js 🐛 Fixed performance regression introduced in 4.1.0 (#12807) 2021-03-23 09:11:24 +00:00
single-use-token_spec.js 🐛 Added multiple use grace period to tokens (#12519) 2021-01-18 17:03:41 +00:00
tag_spec.js Skipped separate count query in .findPage() for limit="all" requests 2020-08-27 01:09:07 +01:00
user_spec.js Extracted core/server/lib/security to @tryghost/security package 2020-08-11 14:06:50 +01:00