Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: emberjs/data
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 427a53fff614fbb0dbf76aaf7ec5aaf6dfe8b660
Choose a base ref
..
head repository: emberjs/data
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 0f5f95e33802698605197ae5e921270b996665f1
Choose a head ref
Showing with 66 additions and 0 deletions.
  1. +35 −0 tests/integration/relationships/belongs-to-test.js
  2. +31 −0 tests/integration/relationships/has-many-test.js
35 changes: 35 additions & 0 deletions tests/integration/relationships/belongs-to-test.js
Original file line number Diff line number Diff line change
@@ -1500,3 +1500,38 @@ testInDebug("A belongsTo relationship warns if malformatted data is pushed into
});
}, /expected the data for the book relationship on a <chapter:1> to be in a JSON API format/);
});

test("belongsTo relationship with links doesn't trigger extra change notifications - #4942", function(assert) {
Chapter.reopen({
book: DS.belongsTo({ async: true })
});

run(() => {
env.store.push({
data: {
type: 'chapter',
id: '1',
relationships: {
book: {
data: { type: 'book', id: '1' },
links: { related: '/chapter/1/book' }
}
}
},
included: [{ type: 'book', id: '1' }]
});
});

let chapter = env.store.peekRecord('chapter', '1');
let count = 0;

chapter.addObserver('book', () => {
count++;
});

run(() => {
chapter.get('book');
});

assert.equal(count, 0);
});
31 changes: 31 additions & 0 deletions tests/integration/relationships/has-many-test.js
Original file line number Diff line number Diff line change
@@ -3334,3 +3334,34 @@ test("deleted records should stay deleted", function(assert) {
);
});
});

test("hasMany relationship with links doesn't trigger extra change notifications - #4942", function(assert) {
run(() => {
env.store.push({
data: {
type: 'book',
id: '1',
relationships: {
chapters: {
data: [{ type: 'chapter', id: '1' }],
links: { related: '/book/1/chapters' }
}
}
},
included: [{ type: 'chapter', id: '1' }]
});
});

let book = env.store.peekRecord('book', '1');
let count = 0;

book.addObserver('chapters', () => {
count++;
});

run(() => {
book.get('chapters');
});

assert.equal(count, 0);
});