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 {
870
870
PFParameterAssert (![className hasPrefix: @" _" ], @" Invalid class name. Class names cannot start with an underscore." );
871
871
}
872
872
873
-
874
873
// /--------------------------------------
875
874
#pragma mark - Serialization helpers
876
875
// /--------------------------------------
@@ -2123,9 +2122,10 @@ - (void)fetch:(NSError **)error {
2123
2122
}
2124
2123
2125
2124
- (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];
2129
2129
}
2130
2130
return [self .taskQueue enqueue: ^BFTask *(BFTask *toAwait) {
2131
2131
return [self fetchAsync: toAwait];
Original file line number Diff line number Diff line change @@ -182,4 +182,20 @@ - (void)testKeyValueCoding {
182
182
XCTAssertEqualObjects ([object valueForKey: @" yarr" ], @" yolo" );
183
183
}
184
184
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
+
185
201
@end
You can’t perform that action at this time.
0 commit comments