File tree Expand file tree Collapse file tree 2 files changed +20
-4
lines changed Expand file tree Collapse file tree 2 files changed +20
-4
lines changed Original file line number Diff line number Diff line change @@ -870,7 +870,6 @@ + (void)_assertValidInstanceClassName:(NSString *)className {
870870 PFParameterAssert (![className hasPrefix: @" _" ], @" Invalid class name. Class names cannot start with an underscore." );
871871}
872872
873-
874873// /--------------------------------------
875874#pragma mark - Serialization helpers
876875// /--------------------------------------
@@ -2123,9 +2122,10 @@ - (void)fetch:(NSError **)error {
21232122}
21242123
21252124- (BFTask *)fetchInBackground {
2126- // TODO: (nlutsenko) Replace with an error?
2127- @synchronized (lock) {
2128- PFParameterAssert (self._state .objectId , @" Can't refresh an object that hasn't been saved to the server." );
2125+ if (!self._state .objectId ) {
2126+ NSError *error = [PFErrorUtilities errorWithCode: kPFErrorMissingObjectId
2127+ message: @" Can't refresh an object that hasn't been saved to the server." ];
2128+ return [BFTask taskWithError: error];
21292129 }
21302130 return [self .taskQueue enqueue: ^BFTask *(BFTask *toAwait) {
21312131 return [self fetchAsync: toAwait];
Original file line number Diff line number Diff line change @@ -182,4 +182,20 @@ - (void)testKeyValueCoding {
182182 XCTAssertEqualObjects ([object valueForKey: @" yarr" ], @" yolo" );
183183}
184184
185+ #pragma mark Fetch
186+
187+ - (void )testFetchObjectWithoutObjectIdError {
188+ PFObject *object = [PFObject objectWithClassName: @" Test" ];
189+
190+ XCTestExpectation *expectation = [self currentSelectorTestExpectation ];
191+ [[object fetchInBackground ] continueWithBlock: ^id (BFTask *task) {
192+ XCTAssertNotNil (task.error );
193+ XCTAssertEqualObjects (task.error .domain , PFParseErrorDomain);
194+ XCTAssertEqual (task.error .code , kPFErrorMissingObjectId );
195+ [expectation fulfill ];
196+ return nil ;
197+ }];
198+ [self waitForTestExpectations ];
199+ }
200+
185201@end
You can’t perform that action at this time.
0 commit comments