diff --git a/lib/neography/rest.rb b/lib/neography/rest.rb index de698ea..7cfa5f4 100644 --- a/lib/neography/rest.rb +++ b/lib/neography/rest.rb @@ -397,7 +397,7 @@ def get_batch(args) when :set_relationship_property {:method => "PUT", :to => "/relationship/#{get_id(args[1])}/properties/#{args[2].keys.first}", :body => args[2].values.first} when :reset_relationship_properties - {:method => "PUT", :to => "/relationship/#{get_id(args[1])}/properties", :body => args[2]} + {:method => "PUT", :to => (args[1].is_a?(String) && args[1].start_with?("{") ? "" : "/relationship/") + "#{get_id(args[1])}/properties", :body => args[2]} when :add_node_to_index {:method => "POST", :to => "/index/node/#{args[1]}", :body => {:uri => (args[4].is_a?(String) && args[4].start_with?("{") ? "" : "/node/") + "#{get_id(args[4])}", :key => args[2], :value => args[3] } } when :add_relationship_to_index diff --git a/spec/integration/rest_batch_spec.rb b/spec/integration/rest_batch_spec.rb index 184f88f..2e9d2d8 100644 --- a/spec/integration/rest_batch_spec.rb +++ b/spec/integration/rest_batch_spec.rb @@ -235,9 +235,6 @@ batch_result.first["body"].first["end"].split('/').last.should == node2["self"].split('/').last end - - - describe "referenced batch" do it "can create a relationship from two newly created nodes" do batch_result = @neo.batch [:create_node, {"name" => "Max"}], [:create_node, {"name" => "Marc"}], [:create_relationship, "friends", "{0}", "{1}", {:since => "high school"}] @@ -285,7 +282,21 @@ existing_index = @neo.find_relationship_index("test_relationship_index", key, value) existing_index.should_not be_nil existing_index.first["self"].should == batch_result.first["body"]["self"] + end + it "can reset the properties of a newly created relationship" do + node1 = @neo.create_node + node2 = @neo.create_node + batch_result = @neo.batch [:create_relationship, "friends", node1, node2, {:since => "high school"}], [:reset_relationship_properties, "{0}", {"since" => "college", "dated" => "yes"}] + batch_result.first.should have_key("id") + batch_result.first.should have_key("from") + existing_relationship = @neo.get_relationship(batch_result.first["body"]["self"].split('/').last) + existing_relationship["type"].should == "friends" + existing_relationship["data"]["since"].should == "college" + existing_relationship["data"]["dated"].should == "yes" + existing_relationship["start"].split('/').last.should == node1["self"].split('/').last + existing_relationship["end"].split('/').last.should == node2["self"].split('/').last + existing_relationship["self"].should == batch_result.first["body"]["self"] end it "can kitchen sink" do