Permalink
Browse files

Fix #1017

  • Loading branch information...
nafg committed May 20, 2011
1 parent 3c54cae commit 05cffe96cb12cccd406ab62eaa8ade4fdbe03684
@@ -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 05cffe9

Please sign in to comment.