mirror of
https://github.com/zhigang1992/RestKit.git
synced 2026-04-01 09:31:17 +08:00
Add coverage for sending synchronous requests with both object loader flavors
This commit is contained in:
@@ -245,5 +245,21 @@
|
||||
assertThatBool([doNotDeleteMe isDeleted], is(equalToBool(NO)));
|
||||
}
|
||||
|
||||
- (void)testShouldNotAssertDuringObjectMappingOnSynchronousRequest {
|
||||
RKManagedObjectStore* store = RKSpecNewManagedObjectStore();
|
||||
RKObjectManager* objectManager = RKSpecNewObjectManager();
|
||||
RKSpecStubNetworkAvailability(YES);
|
||||
objectManager.objectStore = store;
|
||||
|
||||
RKObjectMapping* mapping = [RKManagedObjectMapping mappingForClass:[RKHuman class]];
|
||||
RKManagedObjectLoader* objectLoader = [objectManager loaderWithResourcePath:@"/humans/1"];
|
||||
objectLoader.objectMapping = mapping;
|
||||
RKResponse *response = [objectLoader sendSynchronously];
|
||||
|
||||
NSArray* humans = [RKHuman findAll];
|
||||
assertThatUnsignedInteger([humans count], is(equalToInt(1)));
|
||||
assertThatInteger(response.statusCode, is(equalToInt(200)));
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
||||
@@ -731,4 +731,18 @@
|
||||
assertThat(blockError, is(equalTo(expectedError)));
|
||||
}
|
||||
|
||||
- (void)testShouldNotAssertDuringObjectMappingOnSynchronousRequest {
|
||||
RKObjectManager* objectManager = RKSpecNewObjectManager();
|
||||
|
||||
RKObjectMapping* userMapping = [RKObjectMapping mappingForClass:[RKSpecComplexUser class]];
|
||||
userMapping.rootKeyPath = @"data.STUser";
|
||||
[userMapping mapAttributes:@"firstname", nil];
|
||||
RKObjectLoader* objectLoader = [objectManager loaderWithResourcePath:@"/humans/1"];
|
||||
objectLoader.objectMapping = userMapping;
|
||||
[objectLoader sendSynchronously];
|
||||
RKResponse *response = [objectLoader sendSynchronously];
|
||||
|
||||
assertThatInteger(response.statusCode, is(equalToInt(200)));
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user