diff --git a/lib/neography/node.rb b/lib/neography/node.rb index 8e191bb..7d2106c 100644 --- a/lib/neography/node.rb +++ b/lib/neography/node.rb @@ -19,7 +19,7 @@ def create(props = nil, db = Neography::Rest.new) def load(node, db = Neography::Rest.new) raise ArgumentError.new("syntax deprecated") if node.is_a?(Neography::Rest) - + node = node.first if node.kind_of?(Array) node = db.get_node(node) if (node.to_s.match(/^\d+$/) or node.to_s.split("/").last.match(/^\d+$/)) if node node = self.new(node) diff --git a/spec/integration/node_spec.rb b/spec/integration/node_spec.rb index 4cd4b31..f1d26e1 100644 --- a/spec/integration/node_spec.rb +++ b/spec/integration/node_spec.rb @@ -69,6 +69,19 @@ }.to raise_error(ArgumentError) end + it "can get a node from an index" do + @neo = Neography::Rest.new + new_node = Neography::Node.create("age" => 31, "name" => "Max") + key = generate_text(6) + value = generate_text + @neo.add_node_to_index("test_node_index", key, value, new_node) + node_from_index = @neo.get_node_index("test_node_index", key, value) + existing_node = Neography::Node.load(node_from_index) + existing_node.should_not be_nil + existing_node.neo_id.should_not be_nil + existing_node.neo_id.should == new_node.neo_id + end + it "can get a node that exists via cypher" do new_node = Neography::Node.create("age" => 31, "name" => "Max") cypher = "START n = node({id}) return n"