@@ -300,3 +300,53 @@ def test_concurrent_verification_count_increments(self):
300300
301301 subscription .refresh_from_db ()
302302 self .assertEqual (subscription .verification_count , 5 )
303+
304+ def test_updated_at_changes_when_verification_count_incremented (self ):
305+ """Test that updated_at field is updated when verification count is incremented"""
306+ from django .utils import timezone
307+ import time
308+
309+ subscription = Subscription .objects .create (
310+ email = "timestamp@example.com" ,
311+ is_active = True ,
312+ verification_count = 0
313+ )
314+
315+ # Store initial updated_at
316+ initial_updated_at = subscription .updated_at
317+
318+ # Wait a small amount to ensure timestamp difference
319+ time .sleep (0.1 )
320+
321+ # Call verification endpoint
322+ response = self .client .post (
323+ self .verify_url ,
324+ data = json .dumps ({"email" : "timestamp@example.com" }),
325+ content_type = "application/json"
326+ )
327+
328+ self .assertEqual (response .status_code , status .HTTP_200_OK )
329+
330+ # Refresh and check
331+ subscription .refresh_from_db ()
332+
333+ # Verification count should be incremented
334+ self .assertEqual (subscription .verification_count , 1 )
335+
336+ # updated_at should be newer than initial
337+ self .assertGreater (subscription .updated_at , initial_updated_at )
338+
339+ # Test second increment
340+ second_updated_at = subscription .updated_at
341+ time .sleep (0.1 )
342+
343+ # Call again
344+ self .client .post (
345+ self .verify_url ,
346+ data = json .dumps ({"email" : "timestamp@example.com" }),
347+ content_type = "application/json"
348+ )
349+
350+ subscription .refresh_from_db ()
351+ self .assertEqual (subscription .verification_count , 2 )
352+ self .assertGreater (subscription .updated_at , second_updated_at )
0 commit comments