Skip to content

Commit

Permalink
Merge pull request #1509 from SFDO-Community/feature/1507-change-cust…
Browse files Browse the repository at this point in the history
…om-permission-check

Correcting tests for custom permission
  • Loading branch information
aheber authored Nov 27, 2024
2 parents 7a40051 + d33aa47 commit 5e9c7dd
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 19 deletions.
15 changes: 8 additions & 7 deletions dlrs/main/classes/RollupCalculateJobTest.cls
Original file line number Diff line number Diff line change
Expand Up @@ -261,13 +261,14 @@ private class RollupCalculateJobTest {

RollupCalculateJob job = new RollupCalculateJob(rollupCfg.Id, 'Id != NULL');
String jobId;
System.runAs(new User(Id = UserInfo.getUserId())) {
Test.startTest();
Assert.isTrue(FeatureManagement.checkPermission(permName));
// go into runAs because we need to get the perms recalculated
jobId = Database.executeBatch(job);
Test.stopTest();
}
Test.startTest();
Assert.isTrue(
Utilities.userHasCustomPermission(permName),
'Expected user to have ' + permName
);
// go into runAs because we need to get the perms recalculated
jobId = Database.executeBatch(job);
Test.stopTest();

AsyncApexJob asyncJob = [
SELECT Id, Status, JobItemsProcessed, TotalJobItems
Expand Down
18 changes: 8 additions & 10 deletions dlrs/main/classes/RollupJobTest.cls
Original file line number Diff line number Diff line change
Expand Up @@ -251,16 +251,14 @@ private class RollupJobTest {
insert items;

String jobId;
System.runAs(new User(Id = UserInfo.getUserId())) {
Test.startTest();
Assert.isTrue(
FeatureManagement.checkPermission(permName),
'Expected user to have the ' + permName + ' permission set'
);
// go into runAs because we need to get the perms recalculated
jobId = Database.executeBatch(new RollupJob());
Test.stopTest();
}
Test.startTest();
Assert.isTrue(
Utilities.userHasCustomPermission(permName),
'Expected user to have ' + permName
);
// go into runAs because we need to get the perms recalculated
jobId = Database.executeBatch(new RollupJob());
Test.stopTest();

AsyncApexJob asyncJob = [
SELECT Id, Status, JobItemsProcessed, TotalJobItems
Expand Down
3 changes: 1 addition & 2 deletions dlrs/main/classes/UtilitiesTest.cls
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ public class UtilitiesTest {
if (String.isNotBlank(perm.NamespacePrefix)) {
permName = perm.NamespacePrefix + '__' + perm.DeveloperName;
}
Assert.areEqual(
true,
Assert.isTrue(
Utilities.userHasCustomPermission(permName),
'Expected user to have ' + permName
);
Expand Down

0 comments on commit 5e9c7dd

Please sign in to comment.