Skip to content

Commit

Permalink
handle arrays in get_id, thanks to Phuong CAO
Browse files Browse the repository at this point in the history
  • Loading branch information
maxdemarzi committed Mar 17, 2011
1 parent db4f3db commit fdffbdb
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
3 changes: 2 additions & 1 deletion CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ Maintainer:

Contributors:
* Peter Neubauer
* Ian Dees
* Ian Dees
* Phuong CAO
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
neography (0.0.11)
neography (0.0.12)
httparty (~> 0.7.3)
json

Expand Down
2 changes: 2 additions & 0 deletions lib/neography/rest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,8 @@ def delete(path,options={})

def get_id(id)
case id
when Array
get_id(id.first)
when Hash
id["self"].split('/').last
when String
Expand Down
19 changes: 19 additions & 0 deletions spec/integration/rest_index_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,25 @@
@neo.remove_relationship_from_index("test_index", key, value, new_relationship)
end

it "can find use the results of a node index" do
new_node1 = @neo.create_node
new_node2 = @neo.create_node
key = generate_text(6)
value1 = generate_text
value2 = generate_text
@neo.add_node_to_index("test_index", key, value1, new_node1)
@neo.add_node_to_index("test_index", key, value2, new_node2)
existing_node1 = @neo.get_node_index("test_index", key, value1)
existing_node2 = @neo.get_node_index("test_index", key, value2)
new_relationship = @neo.create_relationship("friends", existing_node1, existing_node2)
new_relationship["start"].should_not be_nil
new_relationship["start"].should == new_node1["self"]
new_relationship["end"].should_not be_nil
new_relationship["end"].should == new_node2["self"]
@neo.remove_node_from_index("test_index", new_node1)
@neo.remove_node_from_index("test_index", new_node2)
end

end


Expand Down

0 comments on commit fdffbdb

Please sign in to comment.