diff --git a/addon/-private/system/relationships/state/has-many.js b/addon/-private/system/relationships/state/has-many.js index ddfefc219a3..f961954d960 100644 --- a/addon/-private/system/relationships/state/has-many.js +++ b/addon/-private/system/relationships/state/has-many.js @@ -89,6 +89,8 @@ export default class ManyRelationship extends Relationship { if (this.members.has(record)) { return; } + + assertPolymorphicType(this.record, this.relationshipMeta, record); super.addRecord(record, idx); // make lazy later this.manyArray.internalAddInternalModels([record], idx); @@ -130,8 +132,6 @@ export default class ManyRelationship extends Relationship { } notifyRecordRelationshipAdded(record, idx) { - assertPolymorphicType(this.record, this.relationshipMeta, record); - this.record.notifyHasManyAdded(this.key, record, idx); } diff --git a/addon/-private/system/relationships/state/relationship.js b/addon/-private/system/relationships/state/relationship.js index d2e07be98cb..582e2fa799a 100644 --- a/addon/-private/system/relationships/state/relationship.js +++ b/addon/-private/system/relationships/state/relationship.js @@ -95,12 +95,7 @@ export default class Relationship { allMembers.forEach(inverseInternalModel => { let relationship = inverseInternalModel._relationships.get(this.inverseKey); - // TODO: there is always a relationship in this case; this guard exists - // because there are tests that fail in teardown after putting things in - // invalid state - if (relationship) { - relationship.inverseDidDematerialize(); - } + relationship.inverseDidDematerialize(); }); }