fix: keep unsubscribed donors as isDonating (#40103)
parent
a7eba00690
commit
0a2f01c9d8
|
@ -149,22 +149,13 @@ export async function cancelDonation(body, app) {
|
|||
const {
|
||||
resource: { id, status_update_time = new Date(Date.now()).toISOString() }
|
||||
} = body;
|
||||
const { User, Donation } = app.models;
|
||||
const { Donation } = app.models;
|
||||
Donation.findOne({ where: { subscriptionId: id } }, (err, donation) => {
|
||||
if (err || !donation) throw Error(err);
|
||||
const userId = donation.userId;
|
||||
log(`Updating donation record: ${donation.subscriptionId}`);
|
||||
donation.updateAttributes({
|
||||
endDate: new Date(status_update_time).toISOString()
|
||||
});
|
||||
|
||||
User.findOne({ where: { id: userId } }, (err, user) => {
|
||||
if (err || !user || !user.donationEmails) throw Error(err);
|
||||
log('Updating user record for donation cancellation');
|
||||
user.updateAttributes({
|
||||
isDonating: false
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -157,10 +157,7 @@ describe('donation', () => {
|
|||
expect(updateDonationAttr).toHaveBeenCalledWith({
|
||||
endDate: new Date(status_update_time).toISOString()
|
||||
});
|
||||
|
||||
expect(updateUserAttr).toHaveBeenCalledWith({
|
||||
isDonating: false
|
||||
});
|
||||
expect(updateUserAttr).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue