Skip to content

Commit d2ff80e

Browse files
committed
Fix: feature owners
1 parent 769b106 commit d2ff80e

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

api/features/multivariate/views.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from drf_yasg.utils import swagger_auto_schema
22
from rest_framework import status, viewsets
33
from rest_framework.decorators import api_view
4-
from rest_framework.exceptions import PermissionDenied
54
from rest_framework.generics import get_object_or_404
65
from rest_framework.response import Response
76

@@ -36,9 +35,7 @@ def get_permissions(self):
3635

3736
def create(self, request, *args, **kwargs):
3837
feature_pk = self.kwargs.get("feature_pk")
39-
feature = get_object_or_404(Feature, pk=feature_pk)
40-
if request.user not in feature.owners.all():
41-
raise PermissionDenied("You do not have permission to perform this action.")
38+
get_object_or_404(Feature, pk=feature_pk)
4239

4340
serializer = self.get_serializer(data=request.data)
4441
if serializer.is_valid():

api/tests/integration/features/multivariate/test_integration_multivariate.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
44
from django.urls import reverse
55
from pytest_lazyfixture import lazy_fixture
66
from rest_framework import status
7+
from rest_framework.test import APIClient
78

89
from features.models import Feature
910
from organisations.models import Organisation
1011
from projects.models import Project
12+
from users.models import FFAdminUser
1113

1214

1315
@pytest.mark.parametrize(
@@ -68,12 +70,9 @@ def test_cannot_create_mv_option_when_feature_id_invalid(client, feature_id, pro
6870
assert response.status_code == status.HTTP_404_NOT_FOUND
6971

7072

71-
@pytest.mark.parametrize(
72-
"client",
73-
[lazy_fixture("admin_client")],
74-
)
75-
def test_cannot_create_mv_option_when_user_is_not_owner_of_the_feature(client, project):
73+
def test_cannot_create_mv_option_when_user_is_not_owner_of_the_feature(project):
7674
# Given
75+
new_user = FFAdminUser.objects.create(email="[email protected]")
7776
organisation = Organisation.objects.create(name="Test Org")
7877
new_project = Project.objects.create(name="Test project", organisation=organisation)
7978
feature = Feature.objects.create(
@@ -91,6 +90,8 @@ def test_cannot_create_mv_option_when_user_is_not_owner_of_the_feature(client, p
9190
"string_value": "bigger",
9291
"default_percentage_allocation": 50,
9392
}
93+
client = APIClient()
94+
client.force_authenticate(user=new_user)
9495
# When
9596
response = client.post(
9697
url,

0 commit comments

Comments
 (0)