-
Notifications
You must be signed in to change notification settings - Fork 429
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(api): validate before creating projects based on current subscrip…
…tion (#2869) Co-authored-by: Matthew Elwell <[email protected]>
- Loading branch information
1 parent
5f3482c
commit f32159e
Showing
8 changed files
with
57 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
from unittest import TestCase, mock | ||
|
||
import pytest | ||
from django.conf import settings | ||
|
||
from organisations.models import Organisation, OrganisationRole | ||
from projects.models import ( | ||
|
@@ -16,8 +17,8 @@ | |
) | ||
from users.models import FFAdminUser, UserPermissionGroup | ||
|
||
mock_request = mock.MagicMock | ||
mock_view = mock.MagicMock | ||
mock_request = mock.MagicMock() | ||
mock_view = mock.MagicMock() | ||
|
||
|
||
@pytest.mark.django_db | ||
|
@@ -371,3 +372,28 @@ def test_regular_user_has_no_destroy_permission(self): | |
|
||
# Then - exception thrown | ||
assert not result | ||
|
||
|
||
@pytest.mark.django_db | ||
def test_free_plan_has_only_fixed_projects_permission(): | ||
# Given | ||
organisation = Organisation.objects.create(name="Test organisation") | ||
|
||
user = FFAdminUser.objects.create(email="[email protected]") | ||
|
||
user.add_organisation(organisation, OrganisationRole.ADMIN) | ||
|
||
project_permissions = ProjectPermissions() | ||
|
||
mock_view = mock.MagicMock(action="create", detail=False) | ||
mock_request = mock.MagicMock( | ||
data={"name": "Test", "organisation": organisation.id}, user=user | ||
) | ||
|
||
# When | ||
for i in range(settings.MAX_PROJECTS_IN_FREE_PLAN): | ||
assert project_permissions.has_permission(mock_request, mock_view) | ||
Project.objects.create(name=f"Test project{i}", organisation=organisation) | ||
|
||
# Then - free projects limit should be exhausted | ||
assert not project_permissions.has_permission(mock_request, mock_view) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
f32159e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
flagsmith-frontend-staging – ./frontend
staging.flagsmith.com
flagsmith-frontend-staging-git-main-flagsmith.vercel.app
flagsmith-frontend-staging-flagsmith.vercel.app
flagsmith-staging-frontend.vercel.app
f32159e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
docs – ./docs
docs-git-main-flagsmith.vercel.app
docs-flagsmith.vercel.app
docs.bullet-train.io
docs.flagsmith.com
f32159e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
flagsmith-frontend-preview – ./frontend
flagsmith-frontend-preview-git-main-flagsmith.vercel.app
flagsmith-frontend-production-native.vercel.app
flagsmith-frontend-preview-flagsmith.vercel.app