mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-15 05:37:22 +01:00
Fix an issue with gifting subs (#14550)
* Translated using Weblate (Chinese (Simplified)) Currently translated at 100.0% (405 of 405 strings) Translated using Weblate (Chinese (Simplified)) Currently translated at 100.0% (2781 of 2781 strings) Translated using Weblate (Portuguese) Currently translated at 100.0% (135 of 135 strings) Translated using Weblate (Portuguese (Brazil)) Currently translated at 100.0% (217 of 217 strings) Translated using Weblate (Portuguese) Currently translated at 100.0% (56 of 56 strings) Translated using Weblate (Portuguese) Currently translated at 100.0% (13 of 13 strings) Translated using Weblate (Portuguese) Currently translated at 100.0% (112 of 112 strings) Translated using Weblate (Portuguese) Currently translated at 100.0% (131 of 131 strings) Translated using Weblate (Portuguese (Brazil)) Currently translated at 100.0% (405 of 405 strings) Translated using Weblate (Portuguese) Currently translated at 81.7% (331 of 405 strings) Translated using Weblate (Portuguese) Currently translated at 100.0% (214 of 214 strings) Translated using Weblate (Portuguese) Currently translated at 62.5% (5 of 8 strings) Translated using Weblate (Portuguese) Currently translated at 100.0% (61 of 61 strings) Translated using Weblate (Portuguese) Currently translated at 63.8% (1777 of 2781 strings) Translated using Weblate (Portuguese) Currently translated at 100.0% (182 of 182 strings) Translated using Weblate (Portuguese) Currently translated at 71.6% (43 of 60 strings) Translated using Weblate (Portuguese) Currently translated at 79.7% (609 of 764 strings) Translated using Weblate (Portuguese) Currently translated at 100.0% (375 of 375 strings) Translated using Weblate (Portuguese) Currently translated at 100.0% (47 of 47 strings) Translated using Weblate (Portuguese) Currently translated at 100.0% (770 of 770 strings) Translated using Weblate (Portuguese) Currently translated at 100.0% (146 of 146 strings) Translated using Weblate (German) Currently translated at 100.0% (404 of 404 strings) Translated using Weblate (German) Currently translated at 79.5% (97 of 122 strings) Translated using Weblate (German) Currently translated at 97.7% (753 of 770 strings) Translated using Weblate (German) Currently translated at 100.0% (146 of 146 strings) Translated using Weblate (Portuguese) Currently translated at 77.0% (94 of 122 strings) Translated using Weblate (Indonesian) Currently translated at 76.7% (310 of 404 strings) Translated using Weblate (Portuguese) Currently translated at 76.2% (93 of 122 strings) Translated using Weblate (Chinese (Traditional)) Currently translated at 85.6% (2381 of 2781 strings) Translated using Weblate (Chinese (Traditional)) Currently translated at 100.0% (60 of 60 strings) Translated using Weblate (Chinese (Traditional)) Currently translated at 100.0% (217 of 217 strings) Translated using Weblate (Chinese (Traditional)) Currently translated at 100.0% (112 of 112 strings) Translated using Weblate (Chinese (Traditional)) Currently translated at 100.0% (267 of 267 strings) Translated using Weblate (Chinese (Traditional)) Currently translated at 100.0% (404 of 404 strings) Translated using Weblate (Chinese (Traditional)) Currently translated at 100.0% (182 of 182 strings) Translated using Weblate (Chinese (Traditional)) Currently translated at 95.8% (732 of 764 strings) Translated using Weblate (Chinese (Traditional)) Currently translated at 100.0% (122 of 122 strings) Translated using Weblate (Chinese (Traditional)) Currently translated at 100.0% (375 of 375 strings) Translated using Weblate (Chinese (Traditional)) Currently translated at 100.0% (770 of 770 strings) Translated using Weblate (Chinese (Traditional)) Currently translated at 100.0% (146 of 146 strings) Translated using Weblate (Portuguese) Currently translated at 74.5% (91 of 122 strings) Translated using Weblate (Portuguese) Currently translated at 72.1% (88 of 122 strings) Co-authored-by: Ana Beatriz <anabeatriz.augusto06@yahoo.com> Co-authored-by: Andressa Murari Sudré <andressa@sudre.com.br> Co-authored-by: Cachinhos <cachnhos@gmail.com> Co-authored-by: Falzart Werefox <muh_fauzi_ramadhan@yahoo.co.id> Co-authored-by: Jay <fallacyofwildlifeconservation@gmail.com> Co-authored-by: Jerry Chen <minecjraft@qq.com> Co-authored-by: Weblate <noreply@weblate.org> Co-authored-by: Yu-Wei Tien <a38498987911@gmail.com> Translate-URL: https://translate.habitica.com/projects/habitica/achievements/de/ Translate-URL: https://translate.habitica.com/projects/habitica/achievements/pt/ Translate-URL: https://translate.habitica.com/projects/habitica/achievements/zh_Hant/ Translate-URL: https://translate.habitica.com/projects/habitica/backgrounds/de/ Translate-URL: https://translate.habitica.com/projects/habitica/backgrounds/pt/ Translate-URL: https://translate.habitica.com/projects/habitica/backgrounds/zh_Hant/ Translate-URL: https://translate.habitica.com/projects/habitica/communityguidelines/de/ Translate-URL: https://translate.habitica.com/projects/habitica/communityguidelines/pt/ Translate-URL: https://translate.habitica.com/projects/habitica/communityguidelines/zh_Hant/ Translate-URL: https://translate.habitica.com/projects/habitica/content/pt/ Translate-URL: https://translate.habitica.com/projects/habitica/content/zh_Hant/ Translate-URL: https://translate.habitica.com/projects/habitica/contrib/pt/ Translate-URL: https://translate.habitica.com/projects/habitica/faq/pt/ Translate-URL: https://translate.habitica.com/projects/habitica/faq/zh_Hant/ Translate-URL: https://translate.habitica.com/projects/habitica/front/pt/ Translate-URL: https://translate.habitica.com/projects/habitica/front/zh_Hant/ Translate-URL: https://translate.habitica.com/projects/habitica/gear/pt/ Translate-URL: https://translate.habitica.com/projects/habitica/gear/zh_Hans/ Translate-URL: https://translate.habitica.com/projects/habitica/gear/zh_Hant/ Translate-URL: https://translate.habitica.com/projects/habitica/generic/pt/ Translate-URL: https://translate.habitica.com/projects/habitica/groups/de/ Translate-URL: https://translate.habitica.com/projects/habitica/groups/id/ Translate-URL: https://translate.habitica.com/projects/habitica/groups/pt/ Translate-URL: https://translate.habitica.com/projects/habitica/groups/pt_BR/ Translate-URL: https://translate.habitica.com/projects/habitica/groups/zh_Hans/ Translate-URL: https://translate.habitica.com/projects/habitica/groups/zh_Hant/ Translate-URL: https://translate.habitica.com/projects/habitica/limited/zh_Hant/ Translate-URL: https://translate.habitica.com/projects/habitica/messages/pt/ Translate-URL: https://translate.habitica.com/projects/habitica/npc/pt/ Translate-URL: https://translate.habitica.com/projects/habitica/overview/pt/ Translate-URL: https://translate.habitica.com/projects/habitica/pets/pt/ Translate-URL: https://translate.habitica.com/projects/habitica/pets/zh_Hant/ Translate-URL: https://translate.habitica.com/projects/habitica/questscontent/pt/ Translate-URL: https://translate.habitica.com/projects/habitica/questscontent/zh_Hant/ Translate-URL: https://translate.habitica.com/projects/habitica/rebirth/pt/ Translate-URL: https://translate.habitica.com/projects/habitica/spells/pt/ Translate-URL: https://translate.habitica.com/projects/habitica/subscriber/pt_BR/ Translate-URL: https://translate.habitica.com/projects/habitica/subscriber/zh_Hant/ Translate-URL: https://translate.habitica.com/projects/habitica/tasks/pt/ Translation: Habitica/Achievements Translation: Habitica/Backgrounds Translation: Habitica/Communityguidelines Translation: Habitica/Content Translation: Habitica/Contrib Translation: Habitica/Faq Translation: Habitica/Front Translation: Habitica/Gear Translation: Habitica/Generic Translation: Habitica/Groups Translation: Habitica/Limited Translation: Habitica/Messages Translation: Habitica/Npc Translation: Habitica/Overview Translation: Habitica/Pets Translation: Habitica/Questscontent Translation: Habitica/Rebirth Translation: Habitica/Spells Translation: Habitica/Subscriber Translation: Habitica/Tasks * gift subscription fix * remove only --------- Co-authored-by: Weblate <noreply@weblate.org> Co-authored-by: Ana Beatriz <anabeatriz.augusto06@yahoo.com> Co-authored-by: Andressa Murari Sudré <andressa@sudre.com.br> Co-authored-by: Cachinhos <cachnhos@gmail.com> Co-authored-by: Falzart Werefox <muh_fauzi_ramadhan@yahoo.co.id> Co-authored-by: Jay <fallacyofwildlifeconservation@gmail.com> Co-authored-by: Jerry Chen <minecjraft@qq.com> Co-authored-by: Yu-Wei Tien <a38498987911@gmail.com> Co-authored-by: SabreCat <sabe@habitica.com>
This commit is contained in:
@@ -235,7 +235,7 @@ describe('payments/index', () => {
|
||||
expect(recipient.purchased.plan.customerId).to.eql('customer-id');
|
||||
});
|
||||
|
||||
it('sets plan.perkMonthCount to zero if user is not subscribed', async () => {
|
||||
it('sets plan.perkMonthCount to 1 if user is not subscribed', async () => {
|
||||
recipient.purchased.plan = plan;
|
||||
recipient.purchased.plan.perkMonthCount = 1;
|
||||
recipient.purchased.plan.customerId = undefined;
|
||||
@@ -246,7 +246,35 @@ describe('payments/index', () => {
|
||||
expect(recipient.purchased.plan.perkMonthCount).to.eql(1);
|
||||
await api.createSubscription(data);
|
||||
|
||||
expect(recipient.purchased.plan.perkMonthCount).to.eql(0);
|
||||
expect(recipient.purchased.plan.perkMonthCount).to.eql(1);
|
||||
});
|
||||
|
||||
it('sets plan.perkMonthCount to 1 if field is not initialized', async () => {
|
||||
recipient.purchased.plan = plan;
|
||||
recipient.purchased.plan.perkMonthCount = -1;
|
||||
recipient.purchased.plan.customerId = undefined;
|
||||
data.sub.key = 'basic_earned';
|
||||
data.gift.subscription.key = 'basic_earned';
|
||||
data.gift.subscription.months = 1;
|
||||
|
||||
expect(recipient.purchased.plan.perkMonthCount).to.eql(-1);
|
||||
await api.createSubscription(data);
|
||||
|
||||
expect(recipient.purchased.plan.perkMonthCount).to.eql(1);
|
||||
});
|
||||
|
||||
it('sets plan.perkMonthCount to 1 if user had previous count but lapsed subscription', async () => {
|
||||
recipient.purchased.plan = plan;
|
||||
recipient.purchased.plan.perkMonthCount = 2;
|
||||
recipient.purchased.plan.customerId = undefined;
|
||||
data.sub.key = 'basic_earned';
|
||||
data.gift.subscription.key = 'basic_earned';
|
||||
data.gift.subscription.months = 1;
|
||||
|
||||
expect(recipient.purchased.plan.perkMonthCount).to.eql(2);
|
||||
await api.createSubscription(data);
|
||||
|
||||
expect(recipient.purchased.plan.perkMonthCount).to.eql(1);
|
||||
});
|
||||
|
||||
it('adds to plan.perkMonthCount if user is already subscribed', async () => {
|
||||
@@ -262,7 +290,7 @@ describe('payments/index', () => {
|
||||
expect(recipient.purchased.plan.perkMonthCount).to.eql(2);
|
||||
});
|
||||
|
||||
it('awards perks if plan.perkMonthCount reaches 3', async () => {
|
||||
it('awards perks if plan.perkMonthCount reaches 3 with existing subscription', async () => {
|
||||
recipient.purchased.plan = plan;
|
||||
recipient.purchased.plan.perkMonthCount = 2;
|
||||
data.sub.key = 'basic_earned';
|
||||
@@ -279,6 +307,29 @@ describe('payments/index', () => {
|
||||
expect(recipient.purchased.plan.consecutive.gemCapExtra).to.eql(5);
|
||||
});
|
||||
|
||||
it('awards perks if plan.perkMonthCount reaches 3 without existing subscription', async () => {
|
||||
recipient.purchased.plan.perkMonthCount = 0;
|
||||
expect(recipient.purchased.plan.perkMonthCount).to.eql(0);
|
||||
expect(recipient.purchased.plan.consecutive.trinkets).to.eql(0);
|
||||
expect(recipient.purchased.plan.consecutive.gemCapExtra).to.eql(0);
|
||||
await api.createSubscription(data);
|
||||
|
||||
expect(recipient.purchased.plan.perkMonthCount).to.eql(0);
|
||||
expect(recipient.purchased.plan.consecutive.trinkets).to.eql(1);
|
||||
expect(recipient.purchased.plan.consecutive.gemCapExtra).to.eql(5);
|
||||
});
|
||||
|
||||
it('awards perks if plan.perkMonthCount reaches 3 without initialized field', async () => {
|
||||
expect(recipient.purchased.plan.perkMonthCount).to.eql(-1);
|
||||
expect(recipient.purchased.plan.consecutive.trinkets).to.eql(0);
|
||||
expect(recipient.purchased.plan.consecutive.gemCapExtra).to.eql(0);
|
||||
await api.createSubscription(data);
|
||||
|
||||
expect(recipient.purchased.plan.perkMonthCount).to.eql(0);
|
||||
expect(recipient.purchased.plan.consecutive.trinkets).to.eql(1);
|
||||
expect(recipient.purchased.plan.consecutive.gemCapExtra).to.eql(5);
|
||||
});
|
||||
|
||||
it('awards perks if plan.perkMonthCount goes over 3', async () => {
|
||||
recipient.purchased.plan = plan;
|
||||
recipient.purchased.plan.perkMonthCount = 2;
|
||||
|
||||
Reference in New Issue
Block a user