diff --git a/Tests/Logic/CoreData/RKEntityMappingTest.m b/Tests/Logic/CoreData/RKEntityMappingTest.m index e9b20942..4b10068c 100644 --- a/Tests/Logic/CoreData/RKEntityMappingTest.m +++ b/Tests/Logic/CoreData/RKEntityMappingTest.m @@ -587,4 +587,22 @@ expect(caughtException.reason).to.equal(@"`requestMapping` is not meant to be invoked on `RKEntityMapping`. You probably want to invoke `[RKObjectMapping requestMapping]`."); } +- (void)testMappingArrayToMutableArray +{ + RKManagedObjectStore *managedObjectStore = [RKTestFactory managedObjectStore]; + RKObjectMapping *mapping = [RKEntityMapping mappingForEntityForName:@"Human" inManagedObjectStore:managedObjectStore]; + [mapping addAttributeMappingsFromDictionary:@{ @"favoriteColors": @"mutableFavoriteColors" }]; + + NSDictionary *dictionary = @{ @"favoriteColors": @[ @"Blue", @"Red" ] }; + RKHuman *human = [NSEntityDescription insertNewObjectForEntityForName:@"Human" inManagedObjectContext:managedObjectStore.mainQueueManagedObjectContext]; + RKMappingOperation *operation = [[RKMappingOperation alloc] initWithSourceObject:dictionary destinationObject:human mapping:mapping]; + RKManagedObjectMappingOperationDataSource *dataSource = [[RKManagedObjectMappingOperationDataSource alloc] initWithManagedObjectContext:managedObjectStore.mainQueueManagedObjectContext cache:nil]; + operation.dataSource = dataSource; + NSError *error = nil; + [operation performMapping:&error]; + + assertThat(human.mutableFavoriteColors, is(equalTo(@[ @"Blue", @"Red" ]))); + assertThat(human.mutableFavoriteColors, is(instanceOf([NSMutableArray class]))); +} + @end diff --git a/Tests/Models/Data Model.xcdatamodel/elements b/Tests/Models/Data Model.xcdatamodel/elements index 4246b97c..4a73f0a5 100644 Binary files a/Tests/Models/Data Model.xcdatamodel/elements and b/Tests/Models/Data Model.xcdatamodel/elements differ diff --git a/Tests/Models/Data Model.xcdatamodel/layout b/Tests/Models/Data Model.xcdatamodel/layout index 2cee6fef..b9c054e4 100644 Binary files a/Tests/Models/Data Model.xcdatamodel/layout and b/Tests/Models/Data Model.xcdatamodel/layout differ diff --git a/Tests/Models/RKHuman.h b/Tests/Models/RKHuman.h index dacec555..ac35df39 100644 --- a/Tests/Models/RKHuman.h +++ b/Tests/Models/RKHuman.h @@ -33,6 +33,7 @@ @property (nonatomic, strong) NSDate *createdAt; @property (nonatomic, strong) NSDate *updatedAt; @property (nonatomic, strong) NSArray *favoriteColors; +@property (nonatomic, strong) NSMutableSet *mutableFavoriteColors; @property (nonatomic, strong) NSSet *cats; @property (nonatomic, strong) NSNumber *favoriteCatID; diff --git a/Tests/Models/RKHuman.m b/Tests/Models/RKHuman.m index a7b76437..3e3e5d06 100644 --- a/Tests/Models/RKHuman.m +++ b/Tests/Models/RKHuman.m @@ -32,6 +32,7 @@ @dynamic createdAt; @dynamic updatedAt; @dynamic favoriteColors; +@dynamic mutableFavoriteColors; @dynamic favoriteCatID; @dynamic favoriteCat;