Skip to content

Commit

Permalink
adding multiple ways to remove a node from an index
Browse files Browse the repository at this point in the history
  • Loading branch information
maxdemarzi committed Jun 27, 2012
1 parent e048609 commit 0d17d0a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
3 changes: 1 addition & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
neography (0.0.26)
neography (0.0.28)
httparty (>= 0.8.1)
json
oj
Expand All @@ -17,7 +17,6 @@ GEM
multi_json (~> 1.0)
multi_xml
json (1.7.3)
json (1.7.3-java)
multi_json (1.3.6)
multi_xml (0.5.1)
net-http-spy (0.2.1)
Expand Down
14 changes: 9 additions & 5 deletions lib/neography/rest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -474,13 +474,17 @@ def get_batch(args)
{:method => "POST", :to => @cypher_path, :body => {:query => args[1]}}
end
when :remove_node_from_index
{:method => "DELETE", :to => "/index/node/#{args[1]}/#{args[2]}/#{args[3]}/#{get_id(args[4])}" }
when :delete_node
{:method => "DELETE", :to => "/node/#{get_id(args[1])}"}
else
case args.size
when 5 then {:method => "DELETE", :to => "/index/node/#{args[1]}/#{args[2]}/#{args[3]}/#{get_id(args[4])}" }
when 4 then {:method => "DELETE", :to => "/index/node/#{args[1]}/#{args[2]}/#{get_id(args[3])}" }
when 3 then {:method => "DELETE", :to => "/index/node/#{args[1]}/#{get_id(args[2])}" }
end
when :delete_node
{:method => "DELETE", :to => "/node/#{get_id(args[1])}"}
else
raise "Unknown option #{args[0]}"
end
end
end

def evaluate_response(response)
code = response.code
Expand Down
13 changes: 9 additions & 4 deletions spec/integration/rest_batch_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -282,15 +282,20 @@
index = generate_text(6)
key = generate_text(6)
value1 = generate_text
value2 = generate_text
value2 = generate_text
value3 = generate_text

node1 = @neo.create_unique_node( index , key , value1 , { "name" => "Max" } )
node2 = @neo.create_unique_node( index , key , value2 , { "name" => "Neo" })
node1 = @neo.create_unique_node(index, key, value1, { "name" => "Max" })
node2 = @neo.create_unique_node(index, key, value2, { "name" => "Neo" })
node3 = @neo.create_unique_node(index, key, value3, { "name" => "Samir"})

batch_result = @neo.batch [:remove_node_from_index, index, key, value1, node1 ], [:remove_node_from_index, index, key, value2, node2 ]
batch_result = @neo.batch [:remove_node_from_index, index, key, value1, node1 ],
[:remove_node_from_index, index, key, node2 ],
[:remove_node_from_index, index, node3 ]

@neo.get_node_index(index, key, value1).should be_nil
@neo.get_node_index(index, key, value2).should be_nil
@neo.get_node_index(index, key, value3).should be_nil
end

end
Expand Down

0 comments on commit 0d17d0a

Please sign in to comment.