@@ -456,6 +456,100 @@ public async Task PostSave_Validates_Domains_Exist()
456
456
Assert . AreEqual ( expectedMessage , display . Notifications . FirstOrDefault ( x => x . NotificationType == NotificationStyle . Warning ) ? . Message ) ;
457
457
} ) ;
458
458
}
459
+
460
+ [ Test ]
461
+ public async Task PostSave_Validates_All_Ancestor_Cultures_Are_Considered ( )
462
+ {
463
+ var sweIso = "sv-SE" ;
464
+ ILocalizationService localizationService = GetRequiredService < ILocalizationService > ( ) ;
465
+ //Create 2 new languages
466
+ localizationService . Save ( new LanguageBuilder ( )
467
+ . WithCultureInfo ( DkIso )
468
+ . WithIsDefault ( false )
469
+ . Build ( ) ) ;
470
+
471
+ localizationService . Save ( new LanguageBuilder ( )
472
+ . WithCultureInfo ( sweIso )
473
+ . WithIsDefault ( false )
474
+ . Build ( ) ) ;
475
+
476
+ IContentTypeService contentTypeService = GetRequiredService < IContentTypeService > ( ) ;
477
+ IContentType contentType = new ContentTypeBuilder ( ) . WithContentVariation ( ContentVariation . Culture ) . Build ( ) ;
478
+ contentTypeService . Save ( contentType ) ;
479
+
480
+ Content content = new ContentBuilder ( )
481
+ . WithoutIdentity ( )
482
+ . WithContentType ( contentType )
483
+ . WithCultureName ( UsIso , "Root" )
484
+ . Build ( ) ;
485
+
486
+ IContentService contentService = GetRequiredService < IContentService > ( ) ;
487
+ contentService . SaveAndPublish ( content ) ;
488
+
489
+ Content childContent = new ContentBuilder ( )
490
+ . WithoutIdentity ( )
491
+ . WithContentType ( contentType )
492
+ . WithParent ( content )
493
+ . WithCultureName ( DkIso , "Barn" )
494
+ . WithCultureName ( UsIso , "Child" )
495
+ . Build ( ) ;
496
+
497
+ contentService . SaveAndPublish ( childContent ) ;
498
+
499
+ Content grandChildContent = new ContentBuilder ( )
500
+ . WithoutIdentity ( )
501
+ . WithContentType ( contentType )
502
+ . WithParent ( childContent )
503
+ . WithCultureName ( sweIso , "Bjarn" )
504
+ . Build ( ) ;
505
+
506
+
507
+ ContentItemSave model = new ContentItemSaveBuilder ( )
508
+ . WithContent ( grandChildContent )
509
+ . WithParentId ( childContent . Id )
510
+ . WithAction ( ContentSaveAction . PublishNew )
511
+ . Build ( ) ;
512
+
513
+ ILanguage enLanguage = localizationService . GetLanguageByIsoCode ( UsIso ) ;
514
+ IDomainService domainService = GetRequiredService < IDomainService > ( ) ;
515
+ var enDomain = new UmbracoDomain ( "/en" )
516
+ {
517
+ RootContentId = content . Id ,
518
+ LanguageId = enLanguage . Id
519
+ } ;
520
+ domainService . Save ( enDomain ) ;
521
+
522
+ ILanguage dkLanguage = localizationService . GetLanguageByIsoCode ( DkIso ) ;
523
+ var dkDomain = new UmbracoDomain ( "/dk" )
524
+ {
525
+ RootContentId = childContent . Id ,
526
+ LanguageId = dkLanguage . Id
527
+ } ;
528
+ domainService . Save ( dkDomain ) ;
529
+
530
+ var url = PrepareApiControllerUrl < ContentController > ( x => x . PostSave ( null ) ) ;
531
+
532
+ HttpResponseMessage response = await Client . PostAsync ( url , new MultipartFormDataContent
533
+ {
534
+ { new StringContent ( JsonConvert . SerializeObject ( model ) ) , "contentItem" }
535
+ } ) ;
536
+
537
+ var body = await response . Content . ReadAsStringAsync ( ) ;
538
+ body = body . TrimStart ( AngularJsonMediaTypeFormatter . XsrfPrefix ) ;
539
+ ContentItemDisplay display = JsonConvert . DeserializeObject < ContentItemDisplay > ( body ) ;
540
+
541
+
542
+ ILocalizedTextService localizedTextService = GetRequiredService < ILocalizedTextService > ( ) ;
543
+ var expectedMessage = localizedTextService . Localize ( "speechBubbles" , "publishWithMissingDomain" , new [ ] { "sv-SE" } ) ;
544
+
545
+ Assert . Multiple ( ( ) =>
546
+ {
547
+ Assert . NotNull ( display ) ;
548
+ Assert . AreEqual ( 1 , display . Notifications . Count ( x => x . NotificationType == NotificationStyle . Warning ) ) ;
549
+ Assert . AreEqual ( expectedMessage , display . Notifications . FirstOrDefault ( x => x . NotificationType == NotificationStyle . Warning ) ? . Message ) ;
550
+ } ) ;
551
+ }
552
+
459
553
[ Test ]
460
554
public async Task PostSave_Validates_All_Cultures_Has_Domains ( )
461
555
{
0 commit comments