@@ -349,9 +349,6 @@ def test_update_stable_version(self):
349
349
self .assertEqual (version_stable .identifier , '1.0.0' )
350
350
351
351
def test_update_inactive_stable_version (self ):
352
- """
353
- Test that stable doesn't get updated when it isn't active
354
- """
355
352
version_post_data = {
356
353
'branches' : [
357
354
{
@@ -471,3 +468,71 @@ def test_unicode(self):
471
468
content_type = 'application/json' ,
472
469
)
473
470
self .assertEqual (resp .status_code , 200 )
471
+
472
+ def test_user_defined_stable_version_with_tags (self ):
473
+
474
+ Version .objects .create (
475
+ project = self .pip ,
476
+ identifier = '0.8.3' ,
477
+ verbose_name = '0.8.3' ,
478
+ active = True ,
479
+ )
480
+
481
+ # A pre-existing active stable branch that was machine created
482
+ Version .objects .create (
483
+ project = self .pip ,
484
+ identifier = 'foo' ,
485
+ type = 'branch' ,
486
+ verbose_name = 'stable' ,
487
+ active = True ,
488
+ machine = True ,
489
+ )
490
+
491
+ version_post_data = {
492
+ 'branches' : [
493
+ {
494
+ 'identifier' : 'origin/master' ,
495
+ 'verbose_name' : 'master' ,
496
+ },
497
+ # A new user-defined stable branch
498
+ {
499
+ 'identifier' : 'origin/stable' ,
500
+ 'verbose_name' : 'stable' ,
501
+ },
502
+ ],
503
+ 'tags' : [
504
+ {
505
+ 'identifier' : '0.9' ,
506
+ 'verbose_name' : '0.9' ,
507
+ },
508
+ {
509
+ 'identifier' : '0.8.3' ,
510
+ 'verbose_name' : '0.8.3' ,
511
+ },
512
+ ],
513
+ }
514
+
515
+ self .client .post (
516
+ '/api/v2/project/{}/sync_versions/' .format (self .pip .pk ),
517
+ data = json .dumps (version_post_data ),
518
+ content_type = 'application/json' ,
519
+ )
520
+
521
+ # Didn't update to newest tag
522
+ version_9 = Version .objects .get (slug = '0.9' )
523
+ self .assertFalse (version_9 .active )
524
+
525
+ # Did update to user-defined stable version
526
+ version_stable = Version .objects .get (slug = 'stable' )
527
+ self .assertFalse (version_stable .machine )
528
+ self .assertTrue (version_stable .active )
529
+ self .assertEqual ('origin/stable' , self .pip .get_stable_version ().identifier )
530
+
531
+ # Check that posting again doesn't change anything from current state.
532
+ self .client .post (
533
+ '/api/v2/project/{}/sync_versions/' .format (self .pip .pk ),
534
+ data = json .dumps (version_post_data ),
535
+ content_type = 'application/json' ,
536
+ )
537
+
538
+ self .assertEqual ('origin/stable' , self .pip .get_stable_version ().identifier )
0 commit comments