Created by
Mike Chale
| trigger ContentDocumentLinkTrigger on ContentDocumentLink (before insert) {
for(ContentDocumentLink l:Trigger.new) {
l.Visibility='AllUsers';
}
}
|
| @isTest
private class ContentDocumentLinkTriggerTest {
@isTest
static void ContentDocumentLinkSharedToAllUsers(){
Account testRecord = new Account(Name = 'Test');
insert testRecord;
ContentNote testNote = new ContentNote(Title = 'Test Note');
insert testNote;
ContentDocumentLink link = new ContentDocumentLink();
link.LinkedEntityId = testRecord.Id;
link.ContentDocumentId = testNote.id;
link.ShareType = 'I';
link.Visibility = 'SharedUsers';
Test.startTest();
insert link;
Test.stopTest();
link = [SELECT Id, Visibility FROM ContentDocumentLink WHERE Id = :link.Id];
System.assertEquals('AllUsers', link.Visibility);
}
}
|