Add test coverage for memory leak due to background policy. refs #548

This commit is contained in:
Blake Watters
2012-03-12 19:03:42 -04:00
parent bbc6500026
commit b8d9a0a423

View File

@@ -39,6 +39,8 @@
@implementation RKRequestTest
- (void)setUp {
[RKTestFactory setUp];
// Clear the cache directory
RKTestClearCacheDirectory();
_methodInvocationCounter = 0;
@@ -202,6 +204,19 @@ request.timeoutInterval = 1.0;
}];
}
- (void)testShouldDeallocTheRequestWhenBackgroundPolicyIsRKRequestBackgroundPolicyCancel {
RKTestNewClient();
RKTestResponseLoader* loader = [RKTestResponseLoader responseLoader];
NSURL* URL = RKTestGetBaseURL();
RKRequest* request = [[RKRequest alloc] initWithURL:URL];
request.backgroundPolicy = RKRequestBackgroundPolicyCancel;
request.delegate = loader;
[request sendAsynchronously];
[loader waitForResponse];
assertThatInteger([request retainCount], is(equalToInteger(1)));
[request release];
}
- (void)testShouldPutTheRequestBackOntoTheQueueWhenBackgroundPolicyIsRKRequestBackgroundPolicyRequeue {
[self stubSharedApplicationWhileExecutingBlock:^{
RKRequestQueue* queue = [RKRequestQueue new];