Robert Whitaker af1d13d3a2 Fix bug where updated webhook options failed to save (fixes #12336) (#12342)
* Fix bug where updated webhook options failed to save

This bug was caused by Mongoose not creating getters/setters for array
elements (https://mongoosejs.com/docs/faq.html#array-changes-not-saved).
So, although the webhook was being updated properly, Mongoose was not
actually committing it to the database. Telling Mongoose that the array
of webhooks has changed via `markModified` fixes the issue.

Additionally, the relevant API test case was only checking whether or
not the webhook returned from the PUT endpoint matched the expected
update. Since the endpoint was returning the updated webhook without
querying the database again, this test case would pass. It has been
updated to check both the returned webhook as well as the version of the
webhook that is saved to the database against the expected. In other
words:

`assert returned === saved === expected`

Fixes #12336

* Call markModified on webhook.options instead of user.webhooks

This tells Mongoose that only the modified webhook's options changed
instead of telling it that the entire user.webhooks array changed,
saving a costly DB update.
2020-07-03 16:48:45 +02:00
2017-10-12 16:44:28 +02:00
2020-06-25 16:50:57 +02:00
2020-07-01 18:20:18 +02:00
2020-07-02 16:50:41 -05:00
2019-10-02 20:09:26 +02:00
2016-09-07 08:44:57 -05:00
2019-10-08 22:57:22 +02:00
2020-05-05 20:31:33 +02:00
2020-04-08 18:44:30 +02:00
2019-08-19 22:43:17 +02:00
2019-10-18 16:52:21 +02:00
2020-05-05 20:31:33 +02:00
2020-04-28 09:17:46 +05:30
2020-07-03 14:36:01 +02:00
2020-07-03 14:36:01 +02:00
2016-05-23 13:58:31 +02:00

Habitica Build Status Code Climate Bountysource

Habitica is an open source habit building program which treats your life like a Role Playing Game. Level up as you succeed, lose HP as you fail, earn money to buy weapons and armor.

We need more programmers! Your assistance will be greatly appreciated. The wiki pages below and the additional pages they link to will tell you how to get started on contributing code and where you can go to seek further help or ask questions:

Habitica's code is licensed as described at https://github.com/HabitRPG/habitica/blob/develop/LICENSE

Found a bug? Please report it in the Report a Bug guild rather than creating an issue (an admin will advise you if a new issue is necessary; usually it is not).

Have any questions about Habitica or its community? See the links in the habitica.com website's Help menu or drop in to Guilds > Tavern Chat to ask questions or chat socially!

S
Description
A habit tracker app which treats your goals like a Role Playing Game.
Readme 1.9 GiB
Languages
JavaScript 51.7%
Vue 23.8%
CSS 23.7%
SCSS 0.7%