Permalink
Browse files

Test that the current thread saveWith method actually saves

  • Loading branch information...
tonyarnold authored and blackgold9 committed Oct 16, 2012
1 parent 870ca22 commit d41d744ece1c1656b6f5cc207dd6f46d29fae128
Showing with 17 additions and 0 deletions.
  1. +17 −0 Project Files/Unit Tests/SaveTests.m
@@ -65,4 +65,21 @@ - (void)testBackgroundSavesActuallySave
expect([fetchedObject hasChanges]).to.beFalsy();
}
+- (void)testCurrentThreadSavesActuallySave
+{
+ __block NSManagedObjectID *objectId;
+ __block NSManagedObject *fetchedObject;
+ [MagicalRecord saveWithBlock:^(NSManagedObjectContext *localContext) {
+ NSManagedObject *inserted = [SingleEntityWithNoRelationships MR_createInContext:localContext];
+ expect([inserted hasChanges]).to.beTruthy();
+ [localContext obtainPermanentIDsForObjects:@[inserted] error:nil];
+ objectId = inserted.objectID;
+ }];
+
+ fetchedObject = [[NSManagedObjectContext MR_rootSavingContext] objectWithID:objectId];
+
+ expect(fetchedObject).toNot.beNil();
+ expect([fetchedObject hasChanges]).to.beFalsy();
+}
+
@end

0 comments on commit d41d744

Please sign in to comment.