Permalink
Browse files

Merge branch 'jstallings-objectloader-error' into release/0.9.4

  • Loading branch information...
2 parents e40200b + e07ea79 commit b726be36f464ed9adbb0e62b532fb2bc50d59ce3 @blakewatters blakewatters committed Mar 30, 2012
Showing with 16 additions and 4 deletions.
  1. +3 −4 Code/CoreData/RKManagedObjectLoader.m
  2. +13 −0 Tests/Logic/CoreData/RKManagedObjectLoaderTest.m
@@ -165,12 +165,11 @@ - (void)processMappingResult:(RKObjectMappingResult*)result {
BOOL success = [self.objectStore save:&error];
if (! success) {
RKLogError(@"Failed to save managed object context after mapping completed: %@", [error localizedDescription]);
- NSMethodSignature* signature = [(NSObject *)self.delegate methodSignatureForSelector:@selector(objectLoader:didFailWithError:)];
+ NSMethodSignature* signature = [(NSObject *)self methodSignatureForSelector:@selector(informDelegateOfError:)];
RKManagedObjectThreadSafeInvocation* invocation = [RKManagedObjectThreadSafeInvocation invocationWithMethodSignature:signature];
[invocation setTarget:self.delegate];
- [invocation setSelector:@selector(objectLoader:didFailWithError:)];
- [invocation setArgument:&self atIndex:2];
- [invocation setArgument:&error atIndex:3];
+ [invocation setSelector:@selector(informDelegateOfError:)];
+ [invocation setArgument:&error atIndex:2];
[invocation invokeOnMainThread];
return;
}
@@ -200,5 +200,18 @@ - (void)testShouldSkipObjectMappingOnRequestCacheHitWhenObjectCachePresent {
}
}
+- (void)testTheOnDidFailBlockIsInvokedOnFailure {
+ RKObjectManager *objectManager = [RKTestFactory objectManager];
+ RKManagedObjectLoader *loader = [objectManager loaderWithResourcePath:@"/fail"];
+ RKTestResponseLoader *responseLoader = [RKTestResponseLoader responseLoader];
+ __block BOOL invoked = NO;
+ loader.onDidFailWithError = ^ (NSError *error) {
+ invoked = YES;
+ };
+ loader.delegate = responseLoader;
+ [loader sendAsynchronously];
+ [responseLoader waitForResponse];
+ assertThatBool(invoked, is(equalToBool(YES)));
+}
@end

0 comments on commit b726be3

Please sign in to comment.