Skip to content

Commit

Permalink
Merge pull request #157 from degzcs/patch-1
Browse files Browse the repository at this point in the history
add props paramenter
  • Loading branch information
maxdemarzi committed Mar 10, 2014
2 parents c77c38f + 39a9053 commit 77fbb91
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
5 changes: 3 additions & 2 deletions lib/neography/rest/batch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -158,14 +158,15 @@ def create_relationship(type, from, to, data = nil)

# RelationshipIndexes

def create_unique_relationship(index, key, value, type, from, to)
def create_unique_relationship(index, key, value, type, from, to, props = nil)
post RelationshipIndexes.unique_path(:index => index) do
{
:key => key,
:value => value,
:type => type,
:start => build_node_uri(from),
:end => build_node_uri(to)
:end => build_node_uri(to),
:properties => props
}
end
end
Expand Down
8 changes: 4 additions & 4 deletions spec/unit/rest/batch_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,13 @@ class Rest

it "creates unique nodes" do
expected_body = [
{ "id" => 0, "method" => "POST", "to" => "/index/relationship/index1?unique", "body" => { "key" => "key1", "value" => "value1", "type" => "type1", "start" => "/node/node1", "end" => "/node/node2" } },
{ "id" => 1, "method" => "POST", "to" => "/index/relationship/index2?unique", "body" => { "key" => "key2", "value" => "value2", "type" => "type2", "start" => "{0}", "end" => "{1}" } }
{ "id" => 0, "method" => "POST", "to" => "/index/relationship/index1?unique", "body" => { "key" => "key1", "value" => "value1", "type" => "type1", "start" => "/node/node1", "end" => "/node/node2", "properties" => "properties" } },
{ "id" => 1, "method" => "POST", "to" => "/index/relationship/index2?unique", "body" => { "key" => "key2", "value" => "value2", "type" => "type2", "start" => "{0}", "end" => "{1}", "properties" => "properties" } }
]

connection.should_receive(:post).with("/batch", json_match(:body, expected_body))
subject.execute [:create_unique_relationship, "index1", "key1", "value1", "type1", "node1", "node2" ],
[:create_unique_relationship, "index2", "key2", "value2", "type2", "{0}", "{1}" ]
subject.execute [:create_unique_relationship, "index1", "key1", "value1", "type1", "node1", "node2","properties" ],
[:create_unique_relationship, "index2", "key2", "value2", "type2", "{0}", "{1}", "properties" ]
end

it "adds relationships to an index" do
Expand Down

0 comments on commit 77fbb91

Please sign in to comment.