Skip to content

Commit

Permalink
Label operations take node hashes, not just ids
Browse files Browse the repository at this point in the history
  • Loading branch information
sosiouxme committed Aug 11, 2013
1 parent a1961bd commit 02295aa
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 15 deletions.
8 changes: 4 additions & 4 deletions lib/neography/rest/node_labels.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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


Expand Down
19 changes: 8 additions & 11 deletions spec/integration/rest_labels_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand All @@ -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

Expand Down

0 comments on commit 02295aa

Please sign in to comment.