Skip to content

Commit

Permalink
Fixed for Issue 14
Browse files Browse the repository at this point in the history
#1
4
  • Loading branch information
afawcettffdc committed Mar 4, 2014
1 parent dc73989 commit 2a9ddae
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
6 changes: 4 additions & 2 deletions rolluptool/src/classes/RollupService.cls
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,10 @@ global with sharing class RollupService
// Add both old and new value to master record Id list for relationship fields to ensure old and new parent master records are updated (re-parenting)
if(relationshipFields.contains(fieldToSearch))
{
masterRecordIds.add((Id) newValue);
masterRecordIds.add((Id) oldValue);
if(newValue!=null)
masterRecordIds.add((Id) newValue);
if(oldValue!=null)
masterRecordIds.add((Id) oldValue);
}
}
}
Expand Down
7 changes: 7 additions & 0 deletions rolluptool/src/classes/RollupServiceTest.cls
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,13 @@ private with sharing class RollupServiceTest
opp.Amount = 100;
insert opp;

// Assert rollup
System.assertEquals(0, [select AnnualRevenue from Account where Id = :account.Id].AnnualRevenue);

// Do an update
opp.Amount = 101;
update opp;

// Assert rollup
System.assertEquals(0, [select AnnualRevenue from Account where Id = :account.Id].AnnualRevenue);
}
Expand Down

0 comments on commit 2a9ddae

Please sign in to comment.