File tree Expand file tree Collapse file tree 2 files changed +23
-1
lines changed
django/thunderstore/api/cyberstorm Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -59,7 +59,7 @@ class CyberstormCreateTeamSerializer(serializers.Serializer):
5959
6060class CyberstormTeamUpdateSerializer (serializers .Serializer ):
6161 donation_link = serializers .CharField (
62- max_length = 1024 , validators = [URLValidator (["https" ])]
62+ allow_null = True , max_length = 1024 , validators = [URLValidator (schemes = ["https" ])]
6363 )
6464
6565
Original file line number Diff line number Diff line change @@ -349,6 +349,28 @@ def test_team_update_succeeds(
349349 assert Team .objects .get (pk = team .pk ).donation_link == new_donation_link
350350
351351
352+ @pytest .mark .django_db
353+ def test_team_update_succeeds_unset_donation_link (
354+ api_client : APIClient ,
355+ user : UserType ,
356+ team : Team ,
357+ ):
358+ TeamMemberFactory (team = team , user = user , role = "owner" )
359+ team .donation_link = "https://example.com"
360+ team .save ()
361+ api_client .force_authenticate (user )
362+
363+ response = api_client .patch (
364+ f"/api/cyberstorm/team/{ team .name } /update/" ,
365+ json .dumps ({"donation_link" : None }),
366+ content_type = "application/json" ,
367+ )
368+
369+ assert response .status_code == 200
370+ assert response .json () == {"donation_link" : None }
371+ assert Team .objects .get (pk = team .pk ).donation_link is None
372+
373+
352374@pytest .mark .django_db
353375def test_team_update_fails_user_not_authenticated (
354376 api_client : APIClient ,
You can’t perform that action at this time.
0 commit comments