Skip to content

Commit

Permalink
discarding nil values, closes #23
Browse files Browse the repository at this point in the history
  • Loading branch information
maxdemarzi committed Jan 10, 2012
1 parent 633206b commit 78766b1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/neography/rest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def get_root

def create_node(*args)
if args[0].respond_to?(:each_pair) && args[0]
options = { :body => args[0].to_json, :headers => {'Content-Type' => 'application/json'} }
options = { :body => args[0].delete_if { |k, v| v.nil? }.to_json, :headers => {'Content-Type' => 'application/json'} }
post("/node", options)
else
post("/node")
Expand Down
7 changes: 7 additions & 0 deletions spec/integration/rest_node_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@
new_node["data"]["name"].should == "Max"
end

it "can create a node with nil properties" do
new_node = @neo.create_node("name" => "Max", "age" => nil )
new_node["data"]["name"].should == "Max"
new_node["data"]["age"].should be_nil
end


it "can create a node with more than one property" do
new_node = @neo.create_node("age" => 31, "name" => "Max")
new_node["data"]["name"].should == "Max"
Expand Down

0 comments on commit 78766b1

Please sign in to comment.