Skip to content

Commit

Permalink
Test that the current thread saveWith method actually saves
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyarnold authored and blackgold9 committed Oct 16, 2012
1 parent 870ca22 commit d41d744
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions Project Files/Unit Tests/SaveTests.m
Expand Up @@ -65,4 +65,21 @@ - (void)testBackgroundSavesActuallySave
expect([fetchedObject hasChanges]).to.beFalsy(); 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 @end

0 comments on commit d41d744

Please sign in to comment.