Skip to content

Commit

Permalink
Merge 448ece6 into feature/238
Browse files Browse the repository at this point in the history
  • Loading branch information
salesforce-org-metaci[bot] authored Jan 16, 2024
2 parents 46183eb + 448ece6 commit 4149c17
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 35 deletions.
26 changes: 0 additions & 26 deletions force-app/main/default/classes/GE_GiftEntryController.cls
Original file line number Diff line number Diff line change
Expand Up @@ -426,42 +426,16 @@ public with sharing class GE_GiftEntryController {
DataImport__c dataImportObject = (DataImport__c)JSON.deserialize(dataImport, DataImport__c.class);

try {
// As currently implemented, Gift Entry already checks everything checked in canUpsertDataImport() before
// allowing access. As a result, canUpsertDataImport() should never return false. It is implemented solely
// as a defense against future modifications since it is an AuraEnabled method that could be used outside
// of the currently implemented flow.
if (!canUpsertDataImport(dataImportObject)) {
throw new UTIL_Permissions.InsufficientPermissionException(System.Label.commonAccessErrorMessage);
}
upsert dataImportObject Id;

return dataImportObject;
} catch (UTIL_Permissions.InsufficientPermissionException e) {
throw new AuraHandledException(e.getMessage());
} catch (Exception e) {
String JSONExceptionData = ERR_ExceptionData.createExceptionWrapperJSONString(e);

throw buildDmlException(JSONExceptionData);
}
}

private static Boolean canUpsertDataImport(DataImport__c dataImportObject) {
if (!UTIL_Permissions.canCreate(UTIL_Namespace.StrAllNSPrefix('DataImport__c'))) {
return false;
}

for (String fieldName : dataImportObject.getPopulatedFieldsAsMap().keySet()) {
if (!UTIL_Permissions.canUpdate(UTIL_Namespace.StrAllNSPrefix('DataImport__c'),
UTIL_Namespace.StrAllNSPrefix(fieldName), false)) {
if (!fieldName.equalsIgnoreCase('Id')) {
return false;
}
}
}

return true;
}

/*******************************************************************************************************
* @description Run the DataImport process on a single gift
* @param dataImport DataImport record to be processed
Expand Down
25 changes: 16 additions & 9 deletions force-app/test/ADDR_Addresses_TEST.cls
Original file line number Diff line number Diff line change
Expand Up @@ -809,10 +809,14 @@ public with sharing class ADDR_Addresses_TEST {
);
insert contact;

Address__c overrideAddress = [SELECT Undeliverable__c
FROM Address__c
WHERE MailingState__c = 'Pennsylvania'];

Address__c overrideAddress;
for (Address__c addr : [SELECT Id, MailingState__c, Undeliverable__c FROM Address__c]) {
if (addr.MailingState__c == 'Pennsylvania') {
overrideAddress = addr;
break;
}
}

Test.startTest();
overrideAddress.Undeliverable__c = true;
update overrideAddress;
Expand Down Expand Up @@ -2229,10 +2233,14 @@ public with sharing class ADDR_Addresses_TEST {
insert testContact;
Test.stopTest();

Address__c testAddress = [SELECT Latest_Start_Date__c, Default_Address__c
FROM Address__c
WHERE MailingState__c = 'Washington'
LIMIT 1];
Address__c testAddress;
for (Address__c addr : [SELECT Id, MailingState__c, Latest_Start_Date__c, Default_Address__c FROM Address__c]) {
if (addr.MailingState__c == 'Washington') {
testAddress = addr;
break;
}
}

System.assertEquals(true, testAddress.Default_Address__c, 'Address should be set as the default address.');
System.assertEquals(System.today(), testAddress.Latest_Start_Date__c, 'The default address latest start date ' +
'should be set to today\'s date.');
Expand Down Expand Up @@ -2548,7 +2556,6 @@ public with sharing class ADDR_Addresses_TEST {
MailingStreet__c, MailingCity__c, MailingState__c,
MailingPostalCode__c, MailingCountry__c
FROM Address__c
ORDER BY MailingState__c
];
}

Expand Down

0 comments on commit 4149c17

Please sign in to comment.