88using RefreshTests . GameServer . Extensions ;
99using Refresh . Database . Models . Levels ;
1010using Refresh . Database . Models . Notifications ;
11+ using Refresh . Interfaces . APIv3 . Endpoints . DataTypes . Request ;
1112using Refresh . Interfaces . Game . Endpoints . DataTypes . Request ;
1213using Refresh . Interfaces . Game . Endpoints . DataTypes . Response ;
1314using Refresh . Interfaces . Game . Types . Levels ;
@@ -704,4 +705,71 @@ public void CanPublishLevelWithSkillRewards()
704705 IEnumerable < GameSkillReward > rewards = context . Database . GetSkillRewardsForLevel ( dbLevel ! ) ;
705706 Assert . That ( rewards , Is . Not . Empty ) ;
706707 }
708+
709+ [ Test ]
710+ public void ReuploadStatusPreserved ( )
711+ {
712+ using TestContext context = this . GetServer ( ) ;
713+ GameUser user = context . CreateUser ( ) ;
714+
715+ using HttpClient client = context . GetAuthenticatedClient ( TokenType . Game , user ) ;
716+
717+ HttpResponseMessage message = client . PostAsync ( $ "/lbp/upload/{ TEST_ASSET_HASH } ", new ReadOnlyMemoryContent ( "LVLb"u8 . ToArray ( ) ) ) . Result ;
718+ Assert . That ( message . StatusCode , Is . EqualTo ( OK ) ) ;
719+
720+ GameLevel dbLevel = context . CreateLevel ( user ) ;
721+ context . Database . UpdateLevel ( new ApiAdminEditLevelRequest ( )
722+ {
723+ IsReUpload = true ,
724+ OriginalPublisher = "glotchmeister69" ,
725+ } , dbLevel , null ) ;
726+
727+ using ( Assert . EnterMultipleScope ( ) )
728+ {
729+ Assert . That ( dbLevel . IsReUpload , Is . True ) ;
730+ Assert . That ( dbLevel . OriginalPublisher , Is . EqualTo ( "glotchmeister69" ) ) ;
731+ }
732+
733+ GameLevelRequest level = new ( )
734+ {
735+ LevelId = dbLevel . LevelId ,
736+ IsAdventure = false ,
737+ Title = "Level" ,
738+ IconHash = "0" ,
739+ Description = new string ( '=' , UgcLimits . DescriptionLimit * 2 ) ,
740+ Location = new GameLocation ( ) ,
741+ GameVersion = 0 ,
742+ RootResource = TEST_ASSET_HASH ,
743+ PublishDate = 0 ,
744+ UpdateDate = 0 ,
745+ MinPlayers = 0 ,
746+ MaxPlayers = 0 ,
747+ EnforceMinMaxPlayers = false ,
748+ SameScreenGame = false ,
749+ SkillRewards = new List < GameSkillReward > ( )
750+ {
751+ new ( )
752+ {
753+ ConditionType = GameSkillRewardCondition . Lives ,
754+ RequiredAmount = 3 ,
755+ Id = 1 ,
756+ Title = "do the stuff" ,
757+ Enabled = true ,
758+ } ,
759+ } ,
760+ } ;
761+
762+ // Republish the level
763+ message = client . PostAsync ( "/lbp/publish" , new StringContent ( level . AsXML ( ) ) ) . Result ;
764+ Assert . That ( message . StatusCode , Is . EqualTo ( OK ) ) ;
765+
766+ context . Database . Refresh ( ) ;
767+ dbLevel = context . Database . GetLevelById ( dbLevel . LevelId ) ! ;
768+
769+ using ( Assert . EnterMultipleScope ( ) )
770+ {
771+ Assert . That ( dbLevel . IsReUpload , Is . True ) ;
772+ Assert . That ( dbLevel . OriginalPublisher , Is . EqualTo ( "glotchmeister69" ) ) ;
773+ }
774+ }
707775}
0 commit comments