Files
Umbraco-CMS/tests/Umbraco.Tests.Common/TestHelpers/DocumentUpdateHelper.cs
Mole c9758edfb1 V15: Add authorization to saves (#18111)
* Re-add authorization

* Add test plumbing

* Add test helper

* Add happy path test

* Remove usage of negation

* Minor DRYup of test code.

---------

Co-authored-by: Andy Butland <abutland73@gmail.com>
2025-01-24 13:45:56 +01:00

32 lines
1006 B
C#

using Umbraco.Cms.Api.Management.ViewModels;
using Umbraco.Cms.Api.Management.ViewModels.Document;
using Umbraco.Cms.Core.Models.ContentEditing;
namespace Umbraco.Cms.Tests.Common.TestHelpers;
public static class DocumentUpdateHelper
{
public static UpdateDocumentRequestModel CreateInvariantDocumentUpdateRequestModel(ContentCreateModel createModel)
{
var updateRequestModel = new UpdateDocumentRequestModel();
updateRequestModel.Template = ReferenceByIdModel.ReferenceOrNull(createModel.TemplateKey);
updateRequestModel.Variants =
[
new DocumentVariantRequestModel
{
Segment = null,
Culture = null,
Name = createModel.InvariantName!,
}
];
updateRequestModel.Values = createModel.InvariantProperties.Select(x => new DocumentValueModel
{
Alias = x.Alias,
Value = x.Value,
});
return updateRequestModel;
}
}