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

fixes automatically quoting value in find_node_labels search #131

Merged
merged 2 commits 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
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