I'm implementing Communities and need to improve my org's security settings. I set Accounts to be private with a sharing rule of "Owner in all internal users" is shared with "All internal users". One of my unit tests fails when the trigger invokes a class that does:
private static Id ewn_new_id, ewn_used_id;
static {
ewn_new_id = [SELECT Id FROM Account WHERE Name = 'Acme'].Id;
}
The error message is:
System.DmlException: Insert failed. First exception on row 0; first error:
CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, RMAtrig: execution of AfterInsert caused by:
System.QueryException: List has no rows for assignment to SObject
Class.RMA: line 8, column 1
Trigger.RMAtrig: line 6, column 1: []
The smoking gun is if I declare the RMA class "without sharing" the test passes. So, the only thing I can think of is unit tests don't run as an internal user?