Split localization service into dedicated services (#13731)
* Rework language service and API * Revert unintended commit of Directory.Build.props * Create OS conditional test for invalid ISO codes * Reintroduce and obsolete old Delete method on ILocalizationService + make new Delete method delete by ISO code + add obsoletion attrs to service implementation * Review comments + utilize new Delete method * Do not allow model reuse when creating a new language * Fix bad merge * Split localization service into dedicated services for language and dictionary item handling * Replaced ILocalizationService usage in management API (as much as can be done for now) * Ensure we can create dictionary items with explicit keys (but no duplicates) * Fix culture controller so it works properly with pagination * Update OpenAPI JSON * Actually update the language being updated... * Unit test for invalid ISO now no longer needs to differ between OS :) * A little bit of code health improvements * A litte less code duplication * Remove duplicate validation
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Cms.Core.Actions;
|
||||
using Umbraco.Cms.Core.Mapping;
|
||||
using Umbraco.Cms.Core.Models;
|
||||
@@ -18,28 +17,28 @@ public class ContentVariantAllowedActionTests : UmbracoTestServerTestBase
|
||||
{
|
||||
private const string UsIso = "en-US";
|
||||
private const string DkIso = "da-DK";
|
||||
private ILocalizationService LocalizationService => GetRequiredService<ILocalizationService>();
|
||||
private ILanguageService LanguageService => GetRequiredService<ILanguageService>();
|
||||
|
||||
private IUserService UserService => GetRequiredService<IUserService>();
|
||||
|
||||
private IUmbracoMapper UmbracoMapper => GetRequiredService<IUmbracoMapper>();
|
||||
|
||||
[SetUp]
|
||||
public void SetUpTestDate()
|
||||
public async Task SetUpTestDate()
|
||||
{
|
||||
var dk = new Language(DkIso, "Danish");
|
||||
LocalizationService.Save(dk);
|
||||
await LanguageService.CreateAsync(dk);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CanCheckIfUserHasAccessToLanguage()
|
||||
public async Task CanCheckIfUserHasAccessToLanguage()
|
||||
{
|
||||
// setup user groups
|
||||
var user = UserBuilder.CreateUser();
|
||||
UserService.Save(user);
|
||||
|
||||
var userGroup = UserGroupBuilder.CreateUserGroup();
|
||||
var languageId = LocalizationService.GetLanguageIdByIsoCode(DkIso);
|
||||
var languageId = (await LanguageService.GetAsync(DkIso))?.Id;
|
||||
userGroup.AddAllowedLanguage(languageId!.Value);
|
||||
UserService.Save(userGroup, new []{ user.Id});
|
||||
var currentUser = UserService.GetUserById(user.Id);
|
||||
|
||||
Reference in New Issue
Block a user