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 support for add_label to batch #132

Merged
merged 1 commit into from
Dec 27, 2013
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
8 changes: 8 additions & 0 deletions lib/neography/rest/batch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 10 additions & 0 deletions spec/unit/rest/batch_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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" },
Expand Down