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

This commit is contained in:
Blake Watters
2012-03-30 09:01:43 -04:00
2 changed files with 16 additions and 4 deletions

View File

@@ -165,12 +165,11 @@
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;
}

View File

@@ -200,5 +200,18 @@
}
}
- (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