Skip to content

Loading…

Failing test for #544 #552

Closed
wants to merge 2 commits into from

1 participant

@ftokarev

No description provided.

@ftokarev

The issue is fixed as of the 11th revision

@ftokarev ftokarev closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 26, 2012
  1. @ftokarev

    Failing test for #544

    ftokarev committed
Commits on Jan 24, 2013
  1. @ftokarev

    Fix for #544

    ftokarev committed
Showing with 27 additions and 0 deletions.
  1. +2 −0 packages/ember-data/lib/system/store.js
  2. +25 −0 packages/ember-data/tests/unit/associations_test.js
View
2 packages/ember-data/lib/system/store.js
@@ -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);
View
25 packages/ember-data/tests/unit/associations_test.js
@@ -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')
Something went wrong with that request. Please try again.