Skip to content

Commit

Permalink
added another test and fixed paths to not quote values outside of get…
Browse files Browse the repository at this point in the history
… params
  • Loading branch information
Ben Guidarelli committed Dec 20, 2013
1 parent 30a94ff commit 34a576d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
12 changes: 9 additions & 3 deletions lib/neography/rest/paths.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,20 @@ def add_path(key, path)
end
end


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

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

def encode(value)
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 34a576d

Please sign in to comment.