mirror of
https://github.com/zhigang1992/MagicalRecord.git
synced 2026-01-12 17:32:18 +08:00
Test that the current thread saveWith method actually saves
This commit is contained in:
committed by
Stephen Vanterpool
parent
870ca22340
commit
d41d744ece
@@ -65,4 +65,21 @@
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user