From 83be1f9a5f74a17d2fc3efa07c08f82514e28185 Mon Sep 17 00:00:00 2001 From: Matt Ruzicka Date: Fri, 20 Dec 2013 17:17:37 -0600 Subject: [PATCH] add support for add_label to batch --- lib/neography/rest/batch.rb | 8 ++++++++ spec/unit/rest/batch_spec.rb | 10 ++++++++++ 2 files changed, 18 insertions(+) diff --git a/lib/neography/rest/batch.rb b/lib/neography/rest/batch.rb index b05b80a..d82aca2 100644 --- a/lib/neography/rest/batch.rb +++ b/lib/neography/rest/batch.rb @@ -112,6 +112,14 @@ def reset_node_properties(id, body) end end + # NodeLabel + + def add_label(id, body) + post build_node_uri(id) + "/labels" do + body + end + end + # NodeRelationships def get_node_relationships(id, direction = nil, types = nil) diff --git a/spec/unit/rest/batch_spec.rb b/spec/unit/rest/batch_spec.rb index 3c0f281..9abcbb6 100644 --- a/spec/unit/rest/batch_spec.rb +++ b/spec/unit/rest/batch_spec.rb @@ -105,6 +105,16 @@ class Rest [:reset_node_properties, "index2", { "key2" => "value2" } ] end + it "adds a node label" do + expected_body = [ + { "id" => 0, "method" => "POST", "to" => "{0}/labels", "body" => "foo" }, + { "id" => 1, "method" => "POST", "to" => "{0}/labels", "body" => "bar" }, + ] + connection.should_receive(:post).with("/batch", json_match(:body, expected_body)) + subject.execute [:add_label, "{0}", "foo"], + [:add_label, "{0}", "bar"] + end + it "gets node relationships" do expected_body = [ { "id" => 0, "method" => "GET", "to" => "/node/id1/relationships/direction1" },