From 02295aab3e249b7bddea22da15fdacfadd3c8e29 Mon Sep 17 00:00:00 2001 From: Luke Meyer Date: Sun, 11 Aug 2013 14:53:21 -0400 Subject: [PATCH] Label operations take node hashes, not just ids --- lib/neography/rest/node_labels.rb | 8 ++++---- spec/integration/rest_labels_spec.rb | 19 ++++++++----------- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/lib/neography/rest/node_labels.rb b/lib/neography/rest/node_labels.rb index 965ad34..27968eb 100644 --- a/lib/neography/rest/node_labels.rb +++ b/lib/neography/rest/node_labels.rb @@ -19,7 +19,7 @@ def list end def get(id) - @connection.get(node_path(:id => id)) + @connection.get(node_path(:id => get_id(id))) end def get_nodes(label) @@ -37,7 +37,7 @@ def add(id, label) ).to_json, :headers => json_content_type } - @connection.post(node_path(:id => id), options) + @connection.post(node_path(:id => get_id(id)), options) end def set(id, label) @@ -47,11 +47,11 @@ def set(id, label) ).to_json, :headers => json_content_type } - @connection.put(node_path(:id => id), options) + @connection.put(node_path(:id => get_id(id)), options) end def delete(id, label) - @connection.delete(delete_path(:id => id, :label => label)) + @connection.delete(delete_path(:id => get_id(id), :label => label)) end diff --git a/spec/integration/rest_labels_spec.rb b/spec/integration/rest_labels_spec.rb index 1d56b52..26a2d7d 100644 --- a/spec/integration/rest_labels_spec.rb +++ b/spec/integration/rest_labels_spec.rb @@ -16,9 +16,8 @@ describe "add_label" do it "can add a label to a node" do new_node = @neo.create_node - new_node_id = new_node["self"].split('/').last - @neo.add_label(new_node_id, "Person") - labels = @neo.get_node_labels(new_node_id) + @neo.add_label(new_node, "Person") + labels = @neo.get_node_labels(new_node) labels.should == ["Person"] end @@ -51,10 +50,9 @@ it "can set a label to a node that already had a label" do new_node = @neo.create_node - new_node_id = new_node["self"].split('/').last - @neo.add_label(new_node_id, "Actor") - @neo.set_label(new_node_id, "Director") - labels = @neo.get_node_labels(new_node_id) + @neo.add_label(new_node, "Actor") + @neo.set_label(new_node, "Director") + labels = @neo.get_node_labels(new_node) labels.should == ["Director"] end @@ -70,10 +68,9 @@ describe "delete_label" do it "can delete a label from a node" do new_node = @neo.create_node - new_node_id = new_node["self"].split('/').last - @neo.set_label(new_node_id, ["Actor", "Director"]) - @neo.delete_label(new_node_id, "Actor") - labels = @neo.get_node_labels(new_node_id) + @neo.set_label(new_node, ["Actor", "Director"]) + @neo.delete_label(new_node, "Actor") + labels = @neo.get_node_labels(new_node) labels.should == ["Director"] end