Fixes mandatory validation issue when creating a new document and a mandatory language has validation problems
This commit is contained in:
@@ -12,6 +12,31 @@ namespace Umbraco.Tests.Web
|
||||
public class ModelStateExtensionsTests
|
||||
{
|
||||
|
||||
[Test]
|
||||
public void Get_Cultures_With_Errors()
|
||||
{
|
||||
var ms = new ModelStateDictionary();
|
||||
var localizationService = new Mock<ILocalizationService>();
|
||||
localizationService.Setup(x => x.GetDefaultLanguageIsoCode()).Returns("en-US");
|
||||
|
||||
ms.AddPropertyError(new ValidationResult("no header image"), "headerImage", null); //invariant property
|
||||
ms.AddPropertyError(new ValidationResult("title missing"), "title", "en-US"); //variant property
|
||||
|
||||
var result = ms.GetCulturesWithErrors(localizationService.Object);
|
||||
|
||||
//even though there are 2 errors, they are both for en-US since that is the default language and one of the errors is for an invariant property
|
||||
Assert.AreEqual(1, result.Count);
|
||||
Assert.AreEqual("en-US", result[0]);
|
||||
|
||||
ms = new ModelStateDictionary();
|
||||
ms.AddCultureValidationError("en-US", "generic culture error");
|
||||
|
||||
result = ms.GetCulturesWithErrors(localizationService.Object);
|
||||
|
||||
Assert.AreEqual(1, result.Count);
|
||||
Assert.AreEqual("en-US", result[0]);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Get_Cultures_With_Property_Errors()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user