mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-28 14:03:48 +03:00
256f16a01f
closes https://github.com/TryGhost/Team/issues/1150 Our override of the base Bookshelf `insert` operation so that our own `formatOnWrite()` method is called on attributes was working on a false assumption that an `attrs` attribute is passed in as it is for the `update` operation. Instead Bookshelf's base update uses the `model.attributes` values to create an `attrs` object that is then passed through the usual `.format()` method meaning that our `insert` override was not actually doing anything. - added a failing regression test for the `formatOnWrite()` override behaviour - adjusted our insert/update overrides to set an internal `_isWriting` property on the model, then if that property is true our `.format()` override (which is called by Bookshelf on a generated `attrs` object during inserts) we manually call our `.formatOnWrite()` method - updated both overrides even though `update` was working for consistency and less cognitive overhead for reasoning between two different approaches |
||
---|---|---|
.. | ||
listeners.test.js | ||
overrides.test.js |