Skip to content

Commit

Permalink
feat(auth): change exclude behavior for mover script
Browse files Browse the repository at this point in the history
Because:

* The product requirements changed regarding excluding customers.
* We no longer want to cancel-only for excluded customers, but now want
  to exclude completely.

This commit:

* Excludes customers in the excluded list completely, rather than just
  excluding them from the cancellation behavior.

Closes FXA-7448
  • Loading branch information
julianpoy authored and vbudhram committed May 12, 2023
1 parent 8ba86e3 commit 56ad66a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ async function init() {
)
.option(
'-e, --exclude [string]',
'Do not sign customers up for the destination plan if they have a subscription to a price in this list',
'Do not touch customers if they have a subscription to a price in this list',
''
)
.option(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,10 @@ export class CustomerPlanMover {

const isExcluded = this.isCustomerExcluded(customer.subscriptions.data);

if (!this.dryRun) {
if (!this.dryRun && !isExcluded) {
await this.cancelSubscription(firestoreSubscription);

if (!isExcluded) await this.createSubscription(customer.id);
await this.createSubscription(customer.id);
}

const report = this.buildReport(customer, account, isExcluded);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,13 @@ describe('CustomerPlanMover', () => {
expect(createSubscriptionStub.notCalled).true;
});

it('does not cancel subscription if customer is excluded', async () => {
customerPlanMover.isCustomerExcluded = sinon.stub().resolves(true);
await customerPlanMover.convertSubscription(mockFirestoreSub);

expect(cancelSubscriptionStub.notCalled).true;
});

it('does not move subscription if subscription is not in active state', async () => {
await customerPlanMover.convertSubscription({
...mockFirestoreSub,
Expand Down

0 comments on commit 56ad66a

Please sign in to comment.