Ensure cancellation works with path patterns against baseURL's that include a path

This commit is contained in:
Blake Watters
2012-10-14 15:32:08 -04:00
parent d823217993
commit 4ee29df72f
2 changed files with 12 additions and 1 deletions

View File

@@ -520,7 +520,8 @@ static NSString *RKMIMETypeFromAFHTTPClientParameterEncoding(AFHTTPClientParamet
}
NSURLRequest *request = [(RKObjectRequestOperation *)operation request];
if ((!methodName || [methodName isEqualToString:[request HTTPMethod]]) && [pathMatcher matchesPath:[[request URL] path] tokenizeQueryStrings:NO parsedArguments:nil]) {
NSString *pathAndQueryString = RKPathAndQueryStringFromURLRelativeToURL([request URL], self.baseURL);
if ((!methodName || [methodName isEqualToString:[request HTTPMethod]]) && [pathMatcher matchesPath:pathAndQueryString tokenizeQueryStrings:NO parsedArguments:nil]) {
[operation cancel];
}
}

View File

@@ -282,6 +282,16 @@
expect([operation isCancelled]).to.equal(NO);
}
- (void)testCancellationByPathMatchForBaseURLWithPath
{
self.objectManager = [RKObjectManager managerWithBaseURL:[NSURL URLWithString:@"http://localhost:4567/object_manager/"]];
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://localhost:4567/object_manager/1234/cancel"]];
RKObjectRequestOperation *operation = [[RKObjectRequestOperation alloc] initWithRequest:request responseDescriptors:self.objectManager.responseDescriptors];
[_objectManager enqueueObjectRequestOperation:operation];
[_objectManager cancelAllObjectRequestOperationsWithMethod:RKRequestMethodGET matchingPathPattern:@":objectID/cancel"];
expect([operation isCancelled]).to.equal(YES);
}
- (void)testShouldProperlyFireABatchOfOperations
{
NSManagedObjectContext *managedObjectContext = [[RKTestFactory managedObjectStore] persistentStoreManagedObjectContext];