Skip to content

Commit e7a2255

Browse files
authored
Copy the global feature policy to the extension property DTO
Copy the global feature policy to the extension property DTO
2 parents 8f4163b + 12de0fe commit e7a2255

3 files changed

Lines changed: 47 additions & 9 deletions

File tree

.claude/settings.local.json

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
{
22
"permissions": {
3-
"allow": [
4-
"Bash(yarn nx g:*)",
5-
"Bash(npx vitest:*)",
6-
"Bash(xargs:*)",
7-
"Bash(dotnet build:*)",
8-
"Bash(git show:*)"
9-
]
3+
"allow": []
104
}
115
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,8 @@ protected virtual ExtensionPropertyDto CreateExtensionPropertyDto(
147147
{
148148
GlobalFeatures = new ExtensionPropertyGlobalFeaturePolicyDto
149149
{
150-
Features = propertyConfig.Policy.Features.Features,
151-
RequiresAll = propertyConfig.Policy.Features.RequiresAll
150+
Features = propertyConfig.Policy.GlobalFeatures.Features,
151+
RequiresAll = propertyConfig.Policy.GlobalFeatures.RequiresAll
152152
},
153153
Features = new ExtensionPropertyFeaturePolicyDto
154154
{
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
using Shouldly;
2+
using Volo.Abp.ObjectExtending;
3+
using Volo.Abp.ObjectExtending.Modularity;
4+
using Xunit;
5+
6+
namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ObjectExtending;
7+
8+
public class CachedObjectExtensionsDtoService_Tests
9+
{
10+
private const string ModuleName = "CachedObjectExtensionsDtoServiceTestModule";
11+
private const string EntityName = "TestEntity";
12+
13+
[Fact]
14+
public void Should_Keep_The_Feature_And_Global_Feature_Policies_Apart()
15+
{
16+
ObjectExtensionManager.Instance.Modules()
17+
.ConfigureModule<ModuleExtensionConfiguration>(ModuleName, module =>
18+
{
19+
module.ConfigureEntity(EntityName, entity =>
20+
{
21+
entity.AddOrUpdateProperty<string>("TestProperty", property =>
22+
{
23+
property.Policy.Features.Features = ["TestFeature"];
24+
property.Policy.Features.RequiresAll = true;
25+
property.Policy.GlobalFeatures.Features = ["TestGlobalFeature"];
26+
property.Policy.GlobalFeatures.RequiresAll = false;
27+
});
28+
});
29+
});
30+
31+
var service = new CachedObjectExtensionsDtoService(new ExtensionPropertyAttributeDtoFactory());
32+
33+
var policy = service.Get()
34+
.Modules[ModuleName]
35+
.Entities[EntityName]
36+
.Properties["TestProperty"]
37+
.Policy;
38+
39+
policy.Features.Features.ShouldBe(["TestFeature"]);
40+
policy.Features.RequiresAll.ShouldBeTrue();
41+
policy.GlobalFeatures.Features.ShouldBe(["TestGlobalFeature"]);
42+
policy.GlobalFeatures.RequiresAll.ShouldBeFalse();
43+
}
44+
}

0 commit comments

Comments
 (0)