Permalink
Browse files

Added test coverage for mapping NSNull to has many relationship. fixes

  • Loading branch information...
1 parent 4e7d6e6 commit fc2fafa7039d49978a90965fd324a9e1274d6d26 @blakewatters blakewatters committed Sep 22, 2011
Showing with 19 additions and 0 deletions.
  1. +19 −0 Specs/CoreData/RKManagedObjectMappingOperationSpec.m
@@ -128,6 +128,25 @@ - (void)itShouldLoadNestedHasManyRelationship {
assertThatBool(success, is(equalToBool(YES)));
}
+- (void)itShouldMapNullToAHasManyRelationship {
+ RKLogConfigureByName("RestKit/ObjectMapping", RKLogLevelTrace);
+ RKSpecNewManagedObjectStore();
+ RKManagedObjectMapping* catMapping = [RKManagedObjectMapping mappingForClass:[RKCat class]];
+ [catMapping mapAttributes:@"name", nil];
+
+ RKManagedObjectMapping* humanMapping = [RKManagedObjectMapping mappingForClass:[RKHuman class]];
+ [humanMapping mapAttributes:@"name", @"favoriteCatID", nil];
+ [humanMapping hasMany:@"cats" withMapping:catMapping];
+
+ NSDictionary* mappableData = [NSDictionary dictionaryWithKeysAndObjects:@"name", @"Blake", @"cats", [NSNull null], nil];
+ RKHuman* human = [RKHuman object];
+ RKManagedObjectMappingOperation* operation = [[RKManagedObjectMappingOperation alloc] initWithSourceObject:mappableData destinationObject:human mapping:humanMapping];
+ NSError* error = nil;
+ BOOL success = [operation performMapping:&error];
+ assertThatBool(success, is(equalToBool(YES)));
+ assertThat(human.cats, is(empty()));
+}
+
- (void)itShouldLoadNestedHasManyRelationshipWithoutABackingClass {
RKManagedObjectStore* objectStore = RKSpecNewManagedObjectStore();
RKManagedObjectMapping* cloudMapping = [RKManagedObjectMapping mappingForEntityWithName:@"RKCloud"];

0 comments on commit fc2fafa

Please sign in to comment.