Browse Source

Copy the global feature policy to the extension property DTO

Copy the global feature policy to the extension property DTO
pull/25994/head
Engincan VESKE 3 days ago
committed by GitHub
parent
commit
e7a225510e
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 8
      .claude/settings.local.json
  2. 4
      framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/CachedObjectExtensionsDtoService.cs
  3. 44
      framework/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/CachedObjectExtensionsDtoService_Tests.cs

8
.claude/settings.local.json

@ -1,11 +1,5 @@
{ {
"permissions": { "permissions": {
"allow": [ "allow": []
"Bash(yarn nx g:*)",
"Bash(npx vitest:*)",
"Bash(xargs:*)",
"Bash(dotnet build:*)",
"Bash(git show:*)"
]
} }
} }

4
framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/CachedObjectExtensionsDtoService.cs

@ -147,8 +147,8 @@ public class CachedObjectExtensionsDtoService : ICachedObjectExtensionsDtoServic
{ {
GlobalFeatures = new ExtensionPropertyGlobalFeaturePolicyDto GlobalFeatures = new ExtensionPropertyGlobalFeaturePolicyDto
{ {
Features = propertyConfig.Policy.Features.Features, Features = propertyConfig.Policy.GlobalFeatures.Features,
RequiresAll = propertyConfig.Policy.Features.RequiresAll RequiresAll = propertyConfig.Policy.GlobalFeatures.RequiresAll
}, },
Features = new ExtensionPropertyFeaturePolicyDto Features = new ExtensionPropertyFeaturePolicyDto
{ {

44
framework/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ObjectExtending/CachedObjectExtensionsDtoService_Tests.cs

@ -0,0 +1,44 @@
using Shouldly;
using Volo.Abp.ObjectExtending;
using Volo.Abp.ObjectExtending.Modularity;
using Xunit;
namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ObjectExtending;
public class CachedObjectExtensionsDtoService_Tests
{
private const string ModuleName = "CachedObjectExtensionsDtoServiceTestModule";
private const string EntityName = "TestEntity";
[Fact]
public void Should_Keep_The_Feature_And_Global_Feature_Policies_Apart()
{
ObjectExtensionManager.Instance.Modules()
.ConfigureModule<ModuleExtensionConfiguration>(ModuleName, module =>
{
module.ConfigureEntity(EntityName, entity =>
{
entity.AddOrUpdateProperty<string>("TestProperty", property =>
{
property.Policy.Features.Features = ["TestFeature"];
property.Policy.Features.RequiresAll = true;
property.Policy.GlobalFeatures.Features = ["TestGlobalFeature"];
property.Policy.GlobalFeatures.RequiresAll = false;
});
});
});
var service = new CachedObjectExtensionsDtoService(new ExtensionPropertyAttributeDtoFactory());
var policy = service.Get()
.Modules[ModuleName]
.Entities[EntityName]
.Properties["TestProperty"]
.Policy;
policy.Features.Features.ShouldBe(["TestFeature"]);
policy.Features.RequiresAll.ShouldBeTrue();
policy.GlobalFeatures.Features.ShouldBe(["TestGlobalFeature"]);
policy.GlobalFeatures.RequiresAll.ShouldBeFalse();
}
}
Loading…
Cancel
Save