 
         dataStack.drop()
     }
+
+    // MARK: - Bug 179 => https://github.com/hyperoslo/Sync/issues/179
+
+    func testConnectMultipleRelationships() {
+        let places = Helper.objectsFromJSON("bug-179-places.json") as! [[String : AnyObject]]
+        let routes = Helper.objectsFromJSON("bug-179-routes.json") as! [String : AnyObject]
+        let dataStack = Helper.dataStackWithModelName("Bug179")
+
+        Sync.changes(places, inEntityNamed: "Place", dataStack: dataStack, completion: nil)
+        Sync.changes([routes], inEntityNamed: "Route", dataStack: dataStack, completion: nil)
+
+        XCTAssertEqual(Helper.countForEntity("Route", inContext:dataStack.mainContext), 1)
+        XCTAssertEqual(Helper.countForEntity("Place", inContext:dataStack.mainContext), 2)
+        let importedRoutes = Helper.fetchEntity("Route", predicate: nil, inContext:dataStack.mainContext)
+        XCTAssertEqual(importedRoutes.count, 1)
+        let importedRouter = importedRoutes.first!
+        XCTAssertEqual(importedRouter.valueForKey("ident") as? String, "1")
+
+        let startPlace = importedRoutes.first!.valueForKey("startPlace") as! NSManagedObject
+        let endPlace = importedRoutes.first!.valueForKey("endPlace") as! NSManagedObject
+        XCTAssertEqual(startPlace.valueForKey("name") as? String, "Here")
+        XCTAssertEqual(endPlace.valueForKey("name") as? String, "There")
+
+        dataStack.drop()
+    }
 }

        XCTAssertEqual(comment.valueForKey("body") as? String, "comment 1")
        XCTAssertEqual((comment.valueForKey("story") as? NSManagedObject)!.valueForKey("remoteID") as? NSNumber, NSNumber(int: 0))
        XCTAssertEqual((comment.valueForKey("story") as? NSManagedObject)!.valueForKey("title") as? String, "story 1")
        
        dataStack.drop()
    }


        XCTAssertEqual(Helper.countForEntity("Fitness", inContext:dataStack.mainContext), 1)
        XCTAssertEqual(Helper.countForEntity("Weight", inContext:dataStack.mainContext), 1)
        XCTAssertEqual(Helper.countForEntity("Measure", inContext:dataStack.mainContext), 1)

        dataStack.drop()
    }

