Skip to content

Commit

Permalink
PRESIDECMS-2613 Add support for and, not, or to help with writing exp…
Browse files Browse the repository at this point in the history
…ressions in xml
  • Loading branch information
DominicWatson committed Sep 27, 2023
1 parent 048715b commit 0a1b879
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion system/services/features/FeatureService.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ component singleton=true autodoc=true displayName="Feature service" {
} );

for( var feature in features ) {
compiled = ReplaceNoCase( compiled, feature, isFeatureEnabled( feature, arguments.siteTemplate ) ? "true" : "false", "all" );
if ( feature != "not" && feature != "and" && feature != "or" ) {
compiled = ReplaceNoCase( compiled, feature, isFeatureEnabled( feature, arguments.siteTemplate ) ? "true" : "false", "all" );
}
}

try {
Expand Down
3 changes: 2 additions & 1 deletion tests/integration/api/features/FeatureServiceTest.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ component extends="testbox.system.BaseSpec"{
var svc = _getService();

expect( svc.isFeatureEnabled( feature="sites || websiteUsers", siteTemplate="" ) ).toBeTrue();
expect( svc.isFeatureEnabled( feature="sites or websiteUsers", siteTemplate="" ) ).toBeTrue();
expect( svc.isFeatureEnabled( feature="sites && assetManager", siteTemplate="" ) ).toBeFalse();
expect( svc.isFeatureEnabled( feature="sites && websiteUsers", siteTemplate="" ) ).toBeTrue();
expect( svc.isFeatureEnabled( feature="sites and websiteUsers", siteTemplate="" ) ).toBeTrue();
expect( svc.isFeatureEnabled( feature="(sites || what) && websiteusers", siteTemplate="" ) ).toBeTrue();
expect( svc.isFeatureEnabled( feature="((sites && what) && websiteusers)", siteTemplate="" ) ).toBeFalse();
expect( svc.isFeatureEnabled( feature="((sites && !what) && websiteusers)", siteTemplate="" ) ).toBeTrue();
Expand Down

0 comments on commit 0a1b879

Please sign in to comment.