Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correcting tests for custom permission #1509

Merged
merged 2 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading