Skip to content

Commit

Permalink
Add response descriptors to response operations of failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
segiddins committed Jan 5, 2014
1 parent 38f1086 commit 6c470aa
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions Tests/Logic/Network/RKManagedObjectRequestOperationTest.m
Expand Up @@ -394,10 +394,15 @@ - (void)testDeletionOfObjectWithEmptyDictionaryResponseTriggersObjectDeletion
- (void)testDeletionOfObjectWithUnmappedResponseBody
{
RKManagedObjectStore *managedObjectStore = [RKTestFactory managedObjectStore];

RKEntityMapping *humanMapping = [RKEntityMapping mappingForEntityForName:@"Human" inManagedObjectStore:managedObjectStore];
[humanMapping addPropertyMapping:[RKAttributeMapping attributeMappingFromKeyPath:@"name" toKeyPath:@"name"]];
RKResponseDescriptor *responseDescriptor = [RKResponseDescriptor responseDescriptorWithMapping:humanMapping method:RKRequestMethodAny pathPattern:nil keyPath:@"human" statusCodes:RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful)];

RKHuman *human = [RKTestFactory insertManagedObjectForEntityForName:@"Human" inManagedObjectContext:managedObjectStore.persistentStoreManagedObjectContext withProperties:nil];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"/humans/success" relativeToURL:[RKTestFactory baseURL]]];
request.HTTPMethod = @"DELETE";
RKManagedObjectRequestOperation *managedObjectRequestOperation = [[RKManagedObjectRequestOperation alloc] initWithRequest:request responseDescriptors:@[]];
RKManagedObjectRequestOperation *managedObjectRequestOperation = [[RKManagedObjectRequestOperation alloc] initWithRequest:request responseDescriptors:@[ responseDescriptor ]];
managedObjectRequestOperation.managedObjectContext = managedObjectStore.persistentStoreManagedObjectContext;
managedObjectRequestOperation.targetObject = human;
[managedObjectRequestOperation start];
Expand Down Expand Up @@ -447,11 +452,16 @@ - (void)testDeletionOfObjectWithResponseDescriptorMappingResponseByKeyPath
- (void)testThatDeletionOfObjectThatHasAlreadyBeenDeletedFromCoreDataDoesNotRaiseException
{
RKManagedObjectStore *managedObjectStore = [RKTestFactory managedObjectStore];

RKEntityMapping *humanMapping = [RKEntityMapping mappingForEntityForName:@"Human" inManagedObjectStore:managedObjectStore];
[humanMapping addPropertyMapping:[RKAttributeMapping attributeMappingFromKeyPath:@"name" toKeyPath:@"name"]];
RKResponseDescriptor *responseDescriptor = [RKResponseDescriptor responseDescriptorWithMapping:humanMapping method:RKRequestMethodAny pathPattern:nil keyPath:@"human" statusCodes:RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful)];

RKHuman *human = [RKTestFactory insertManagedObjectForEntityForName:@"Human" inManagedObjectContext:managedObjectStore.persistentStoreManagedObjectContext withProperties:nil];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"/humans/success" relativeToURL:[RKTestFactory baseURL]]];
request.HTTPMethod = @"DELETE";
[managedObjectStore.persistentStoreManagedObjectContext saveToPersistentStore:nil];
RKManagedObjectRequestOperation *managedObjectRequestOperation = [[RKManagedObjectRequestOperation alloc] initWithRequest:request responseDescriptors:@[]];
RKManagedObjectRequestOperation *managedObjectRequestOperation = [[RKManagedObjectRequestOperation alloc] initWithRequest:request responseDescriptors:@[ responseDescriptor ]];
managedObjectRequestOperation.managedObjectContext = managedObjectStore.persistentStoreManagedObjectContext;
managedObjectRequestOperation.targetObject = human;
[managedObjectRequestOperation start];
Expand Down

0 comments on commit 6c470aa

Please sign in to comment.