Skip to content

Commit

Permalink
fixing Issue #101
Browse files Browse the repository at this point in the history
  • Loading branch information
maxdemarzi committed Jul 18, 2013
1 parent da45cb3 commit 1e2c40a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/neography/node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
13 changes: 13 additions & 0 deletions spec/integration/node_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 1e2c40a

Please sign in to comment.