Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add delete_relationship to batch command #51

Merged
merged 2 commits into from
Jul 30, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/neography/rest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,8 @@ def get_batch(args)
{:method => "POST", :to => (args[2].is_a?(String) && args[2].start_with?("{") ? "" : "/node/") + "#{get_id(args[2])}/relationships", :body => {:to => (args[3].is_a?(String) && args[3].start_with?("{") ? "" : "/node/") + "#{get_id(args[3])}", :type => args[1], :data => args[4] } }
when :create_unique_relationship
{:method => "POST", :to => "/index/relationship/#{args[1]}?unique", :body => {:key => args[2], :value => args[3], :type => args[4], :start => (args[5].is_a?(String) && args[5].start_with?("{") ? "" : "/node/") + "#{get_id(args[5])}", :end=> (args[6].is_a?(String) && args[6].start_with?("{") ? "" : "/node/") + "#{get_id(args[6])}"} }
when :delete_relationship
{:method => "DELETE", :to => "/relationship/#{get_id(args[1])}"}
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
Expand Down
12 changes: 12 additions & 0 deletions spec/integration/rest_batch_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,18 @@
batch_result.first["body"]["end"].split('/').last.should == node2["self"].split('/').last
end

it "can delete a single relationship" do
node1 = @neo.create_node
node2 = @neo.create_node
batch_result = @neo.batch [:create_relationship, "friends", node1, node2, {:since => "time immemorial"}]
batch_result.should_not be_nil
batch_result[0]["status"].should == 201
id = batch_result.first["body"]["self"].split("/").last
batch_result = @neo.batch [:delete_relationship, id]
batch_result[0]["status"].should == 204
batch_result[0]["from"].should == "/relationship/#{id}"
end

it "can create a unique relationship" do
index_name = generate_text(6)
key = generate_text(6)
Expand Down