Skip to content
This repository was archived by the owner on Jan 22, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion addon/models/resource.js
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ const Resource = Ember.Object.extend(ResourceOperationsMixin, {
get() {
let relationships = Object.keys(this._relationships).filter( (relation) => {
let ref = this._relationships[relation];
return !!ref.previous || (ref.removals && ref.removals.length) ||
return !!ref.changed || (ref.removals && ref.removals.length) ||
(ref.added && ref.added.length);
});
return Ember.A(relationships);
Expand Down
10 changes: 10 additions & 0 deletions tests/unit/models/resource-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,9 +313,19 @@ test('#addRelationship tracks relationships changes', function(assert) {
assert.equal(post._relationships.author.changed.id, '1', 'changed id is 1');
assert.equal(post._relationships.author.changed.type, 'authors', 'changed type is authors');

let changed = post.get('changedRelationships');
assert.equal(changed.length, 1, 'one changedRelationship');
assert.equal(changed[0], 'author', 'changedRelationship is "author"');

post.addRelationship('comments', '1');
assert.ok(post._relationships.comments.added, 'comments relation added');
assert.equal(post._relationships.comments.added.length, 1, 'one comments relation added');

changed = post.get('changedRelationships');
assert.equal(changed.length, 2, 'two changedRelationships');
assert.equal(changed.filter(i => { return i==="comments"; }).length,
'1', 'changedRelationships contains "comments"');

post.addRelationship('comments', '2');
assert.equal(post._relationships.comments.added.length, 2, 'two comments relation added');
});
Expand Down