Skip to content

Commit

Permalink
populating foreign key in AssociationCollection.build()
Browse files Browse the repository at this point in the history
  • Loading branch information
danschultz committed May 24, 2011
1 parent 3680aff commit 99017ca
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/mesh/model/associations/AssociationCollection.as
Expand Up @@ -83,6 +83,7 @@ package mesh.model.associations
for each (var property:Object in properties) {
var entity:Entity = new definition.target();
copy(property, entity);
populateInverseAssociation(entity);
result.push(entity);
}
return result.length == 1 ? result.pop() : result;
Expand Down
9 changes: 9 additions & 0 deletions tests/mesh/model/AssociationCollectionTests.as
Expand Up @@ -10,6 +10,7 @@ package mesh.model
import org.flexunit.assertThat;
import org.hamcrest.collection.array;
import org.hamcrest.collection.emptyArray;
import org.hamcrest.core.isA;
import org.hamcrest.object.equalTo;

use namespace flash_proxy;
Expand Down Expand Up @@ -44,6 +45,14 @@ package mesh.model
_collection.callback("afterLoad");
}

[Test]
public function testBuild():void
{
var order:Order = _collection.build({total:15});
assertThat(order.customer.flash_proxy::object, isA(Customer));
assertThat(order.total, equalTo(15));
}

[Test]
public function testRevertRestoresToOriginalEntities():void
{
Expand Down

0 comments on commit 99017ca

Please sign in to comment.