Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failing test for #544 #552

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/ember-data/lib/system/store.js
Expand Up @@ -327,6 +327,8 @@ DS.Store = Ember.Object.extend(DS._Mappable, {
// this clientId.
this.recordCache[clientId] = record;

record.materializeData();

// Set the properties specified on the record.
record.setProperties(properties);

Expand Down
25 changes: 25 additions & 0 deletions packages/ember-data/tests/unit/associations_test.js
Expand Up @@ -282,6 +282,31 @@ test("it is possible to add a new item to an association", function() {
equal(get(person, 'tags').objectAt(1), tag, "newly added association works");
});

test("it is possible to add a new item to an association at the time of record creation", function () {
var Tag = DS.Model.extend({
name: DS.attr('string')
});

var Person = DS.Model.extend({
name: DS.attr('string'),
tags: DS.hasMany(Tag)
});

Tag.reopen({
people: DS.belongsTo(Person)
});

var store = DS.Store.create();

store.load(Person, { id: 1, name: "Tom Dale"});

var person = store.find(Person, 1);

var tag = store.createRecord(Tag, { name: "js", people: person });

equal(get(person, 'tags').objectAt(0), tag, "newly added association works");
});

test("it is possible to remove an item from an association", function() {
var Tag = DS.Model.extend({
name: DS.attr('string')
Expand Down