Added Spec Tests for 2 Operations
authorSamir Ahmed <samirahmed2013@gmail.com>
Wed, 20 Jun 2012 06:00:56 +0000 (23:00 -0700)
committerSamir Ahmed <samirahmed2013@gmail.com>
Wed, 20 Jun 2012 06:00:56 +0000 (23:00 -0700)
Added to spec tests to very that the operations...

For testing batch delete node :
 - 2 node created one by one
 - Nodes deleted in batch
 - Get nodes results should be nil

For testing batch remove node :
 - Create two nodes with indicies one by one
 - In batch remove the node from the indidicies
 - Search for exact nodes should be nil

lib/neography/rest.rb
spec/integration/rest_batch_spec.rb

index 4dc816a70b3d32a93ea737e897961c00408d7812..4bf8ea4dcc6ef62604868238a84804deae06802f 100644 (file)
@@ -474,11 +474,7 @@ module Neography
               {:method => "POST", :to => @cypher_path, :body => {:query => args[1]}}
             end
           when :remove_node_from_index
-                       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
+                        {: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
index b4d2bf41534e59f2725091d9effd6a3b1c3f0ee4..d2355611b93f6e661f041178b932d0e08e41a439 100644 (file)
@@ -266,6 +266,32 @@ describe Neography::Rest do
       batch_result.first["body"]["data"][0][0]["self"].split('/').last.should == id
     end  
   
+       it "can delete a node in batch" do
+               
+               node1 = @neo.create_node
+               node2 = @neo.create_node
+               id1 = node1['self'].split('/').last
+               id2 = node2['self'].split('/').last
+               batch_result = @neo.batch [:delete_node, id1 ], [:delete_node, id2]
+               @neo.get_node(node1).should be_nil
+               @neo.get_node(node2).should be_nil
+
+       end
+
+       it "can remove a node from an index in batch " do
+               index = generate_text(6)
+               key = generate_text(6)
+               value1 = generate_text
+               value2 = generate_text 
+               
+               node1 = @neo.create_unique_node( index , key  , value1  , { "name" => "Max" } )
+               node2 = @neo.create_unique_node( index , key , value2 , { "name" => "Neo" }) 
+               
+               batch_result = @neo.batch [:remove_node_from_index, index, key, value1, node1 ], [:remove_node_from_index, index, key, value2, node2 ]
+               
+               @neo.get_node_index(index, key, value1).should be_nil
+               @neo.get_node_index(index, key, value2).should be_nil
+       end
 
   end
 
@@ -365,4 +391,4 @@ describe Neography::Rest do
 
   end
   
-end
\ No newline at end of file
+end