Permalink
Browse files

Fix #1017

  • Loading branch information...
1 parent c2c4358 commit 542f5d8df7030911dce96764c4b2d89567baec07 @nafg nafg committed May 20, 2011
@@ -39,8 +39,7 @@ trait ManyToMany extends BaseKeyedMapper {
* If they are all successful returns true.
*/
abstract override def save = {
- super.save &&
- manyToManyFields.forall(_.save)
+ manyToManyFields.forall(_.save) && super.save
}
/**
@@ -86,6 +86,34 @@ object ManyToManySpec extends Specification("ManyToMany Specification") {
person.companies += company
person.companies.length must_== 1
}
+// "count unsaved children of a saved entity" in {
+// setupDB
+// val person = new Person
+// val company = new Company
+// person.companies += company
+// person.save
+// person.companies.length must_== 1
+// }
+ "count saved children of a saved entity" in {
+ setupDB
+ val person = new Person
+ val company = new Company
+ company.save
+ person.companies += company
+ person.save
+ person.companies.length must_== 1
+ }
+ "count saved children of a saved entity after refresh" in {
+ setupDB
+ val person = new Person
+ person.save
+ val company = new Company
+ company.save
+ person.companies += company
+ person.save
+ person.companies.refresh
+ person.companies.length must_== 1
+ }
}
}

0 comments on commit 542f5d8

Please sign in to comment.