diff --git a/AFNetworking/AFURLConnectionOperation.m b/AFNetworking/AFURLConnectionOperation.m index 52fe7f9..71d34f2 100644 --- a/AFNetworking/AFURLConnectionOperation.m +++ b/AFNetworking/AFURLConnectionOperation.m @@ -267,6 +267,8 @@ static BOOL AFSecKeyIsEqualToKey(SecKeyRef key1, SecKeyRef key2) { #endif - (id)initWithRequest:(NSURLRequest *)urlRequest { + NSParameterAssert(urlRequest); + self = [super init]; if (!self) { return nil; diff --git a/Tests/AFURLConnectionOperationTests.m b/Tests/AFURLConnectionOperationTests.m index 7982789..4b3cbe3 100644 --- a/Tests/AFURLConnectionOperationTests.m +++ b/Tests/AFURLConnectionOperationTests.m @@ -37,6 +37,10 @@ #pragma mark - +- (void)testInitWithNilRequestRaisesException { + expect(^{ (void)[[AFURLConnectionOperation alloc] initWithRequest:nil]; }).to.raiseAny(); +} + - (void)testThatAFURLConnectionOperationInvokesWillSendRequestForAuthenticationChallengeBlock { NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"/path" relativeToURL:self.baseURL]]; AFURLConnectionOperation *operation = [[AFURLConnectionOperation alloc] initWithRequest:request];