@@ -284,6 +284,38 @@ def test_update_project_setting_invalid_option(self):
284
284
285
285
assert response .data == {"detail" : "Invalid settings option" }
286
286
287
+ @with_feature ("organizations:performance-view" )
288
+ @with_feature ("organizations:performance-manage-detectors" )
289
+ def test_project_admins_can_manage_detectors (self ):
290
+ self .login_as (user = self .user , superuser = False )
291
+ response = self .get_success_response (
292
+ self .project .organization .slug ,
293
+ self .project .slug ,
294
+ n_plus_one_db_queries_detection_enabled = False ,
295
+ method = "put" ,
296
+ status_code = status .HTTP_200_OK ,
297
+ )
298
+
299
+ assert not response .data ["n_plus_one_db_queries_detection_enabled" ]
300
+
301
+ @with_feature ("organizations:performance-view" )
302
+ @with_feature ("organizations:performance-manage-detectors" )
303
+ def test_project_members_cannot_manage_detectors (self ):
304
+ user = self .create_user ("member@localhost" )
305
+ self .create_member (
306
+ organization = self .project .organization ,
307
+ user = user ,
308
+ role = "member" ,
309
+ )
310
+ self .login_as (user = user )
311
+ self .get_error_response (
312
+ self .project .organization .slug ,
313
+ self .project .slug ,
314
+ n_plus_one_db_queries_detection_enabled = False ,
315
+ method = "put" ,
316
+ status_code = status .HTTP_403_FORBIDDEN ,
317
+ )
318
+
287
319
@patch ("sentry.api.base.create_audit_entry" )
288
320
@with_feature ("organizations:performance-view" )
289
321
def test_changing_admin_settings_creates_audit_log (self , create_audit_entry : MagicMock ):
0 commit comments