Skip to content

Commit

Permalink
Merge pull request #131 from barnjamin/master
Browse files Browse the repository at this point in the history
fixes automatically quoting value in find_node_labels search
  • Loading branch information
maxdemarzi committed Dec 27, 2013
2 parents 16e2f38 + 34a576d commit 6f39b74
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/neography/rest/node_labels.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class NodeLabels
add_path :base, "/labels"
add_path :node, "/node/:id/labels"
add_path :nodes, "/label/:label/nodes"
add_path :find, "/label/:label/nodes?:property=%22:value%22"
add_path :find, "/label/:label/nodes?:property=:value"
add_path :delete, "/node/:id/labels/:label"

def initialize(connection)
Expand Down
14 changes: 12 additions & 2 deletions lib/neography/rest/paths.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,19 @@ def add_path(key, path)
end
end


def build_path(path, attributes)
path.gsub(/:([\w_]*)/) do
encode(attributes[$1.to_sym].to_s)
p = String.new(path)
p.gsub!(/=:([\w_]*)/) do
if $1.to_sym == :value and attributes[$1.to_sym].class == String
"=%22"+encode(attributes[$1.to_sym].to_s)+"%22";
else
"="+encode(attributes[$1.to_sym].to_s)
end
end

p.gsub(/:([\w_]*)/) do
encode(attributes[$1.to_sym].to_s)
end
end

Expand Down
7 changes: 6 additions & 1 deletion spec/unit/rest/labels_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,16 @@ class Rest
subject.get_nodes("person")
end

it "find nodes for labels and property" do
it "find nodes for labels and property string" do
connection.should_receive(:get).with("/label/person/nodes?name=%22max%22")
subject.find_nodes("person", {:name => "max"})
end

it "find nodes for labels and property integer" do
connection.should_receive(:get).with("/label/person/nodes?age=26")
subject.find_nodes("person", {:age => 26})
end

it "can add a label to a node" do
options = {
:body => '["Actor"]',
Expand Down

0 comments on commit 6f39b74

Please sign in to comment.