@@ -531,6 +531,19 @@ def test_non_creator_cannot_cancel_request(self):
531531 "You cannot cancel someone else's request" , patch_response .data ["status" ][0 ]
532532 )
533533
534+ def test_user_cant_approve_own_request (self ):
535+ """User should not be able to approve own request"""
536+ self .client .force_authenticate (user = self .creator_user )
537+ patch_data = {"status" : "approved" }
538+ patch_response = self .client .patch (
539+ get_lending_request_detail_url (self .request_id ), patch_data
540+ )
541+ self .assertEqual (patch_response .status_code , status .HTTP_400_BAD_REQUEST )
542+ self .assertIn ("status" , patch_response .data )
543+ self .assertIn (
544+ "You cannot approve your own request" , patch_response .data ["status" ][0 ]
545+ )
546+
534547 def test_creation_creates_system_linelineentry (self ):
535548 """
536549 Verify that when a lending request is created, a system message
@@ -556,7 +569,7 @@ def test_creator_update_status_creates_system_timelineentry(self):
556569 """
557570 # Update the status as the creator.
558571 self .client .force_authenticate (user = self .creator_user )
559- patch_data = {"status" : "approved " }
572+ patch_data = {"status" : "cancelled " }
560573 patch_response = self .client .patch (
561574 get_lending_request_detail_url (self .request_id ), patch_data
562575 )
@@ -569,7 +582,7 @@ def test_creator_update_status_creates_system_timelineentry(self):
569582
570583 # Verify the timelineentry text matches the expected system message.
571584 # Expected text: "Status endret fra {translated old status} til {translated new status}."
572- expected_text = LENDING_REQUEST_TRANSLATION_MAP ["approved " ]
585+ expected_text = LENDING_REQUEST_TRANSLATION_MAP ["cancelled " ]
573586 system_timelineentry = updated_request .timeline_entries .order_by (
574587 "created_at"
575588 ).last ()
0 commit comments