Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Organisation reverts to free plan #3096

Merged
merged 19 commits into from
Dec 18, 2023

Conversation

zachaysan
Copy link
Contributor

Thanks for submitting a PR! Please check the boxes below:

  • I have run pre-commit to check linting
  • I have added information to docs/ if required so people know about the feature!
  • I have filled in the "Changes" section below?
  • I have filled in the "How did you test this code" section below?
  • I have used a Conventional Commit title for this Pull Request

Changes

When a subscription cancels we lead to a mismatch in what the user expects, since they're no longer on the former subscription. What this change does is wipe out most of the subscription data and reverts it to what is at present for an empty free subscription.

How did you test this code?

With a test through a task.

Copy link

vercel bot commented Dec 5, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 18, 2023 2:24pm
flagsmith-frontend-preview ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 18, 2023 2:24pm
flagsmith-frontend-staging ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 18, 2023 2:24pm

Copy link
Contributor

github-actions bot commented Dec 5, 2023

Uffizzi Preview deployment-42214 was deleted.

@codecov-commenter
Copy link

codecov-commenter commented Dec 6, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (fc3bce0) 96.11% compared to head (027ca9e) 96.12%.
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3096      +/-   ##
==========================================
+ Coverage   96.11%   96.12%   +0.01%     
==========================================
  Files        1059     1059              
  Lines       32037    32136      +99     
==========================================
+ Hits        30792    30891      +99     
  Misses       1245     1245              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@gagantrivedi gagantrivedi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks really good now! Just some minor comments

assert subscription.notes == notes


def test_finish_subscription_cancellation(db: None) -> None:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should add an assert statement here somewhere to make sure the task was scheduled correctly?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that's a good call. Added.

@@ -38,6 +38,17 @@ def send_org_over_limit_alert(organisation_id):
)


@register_task_handler()
def send_org_subscription_cancelled_alert(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do understand this is a tiny method, but can we add a test for this as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haha, sure. Added one.


# When
send_org_subscription_cancelled_alert(
organisation_name="Nike",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nike here makes me feel a bit uncomfortable for some reason… can we rename it to test or something

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree with this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I forget we're developing Open Source and Nike could ruffle feathers. In general, I like realistic named tests, but for this one it's the right call to change it something neutral.

Comment on lines +88 to +89
# Subscription has been immediately transformed to free.
assert subscription.cancellation_date is None
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feels like there should be more asserts here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test was originally targeted at chargebee and other tests enforced the other checks, but I've added more asserts because there is no downside.


# When
send_org_subscription_cancelled_alert(
organisation_name="Nike",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree with this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Issue related to the REST API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants