Skip to content

Commit

Permalink
letting reset properties take a newly created relationship
Browse files Browse the repository at this point in the history
  • Loading branch information
maxdemarzi committed Mar 6, 2012
1 parent 8a8e13c commit 644145b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/neography/rest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 14 additions & 3 deletions spec/integration/rest_batch_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"}]
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 644145b

Please sign in to comment.