neography 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
data/lib/neography/connection.rb
CHANGED
@@ -98,13 +98,13 @@ module Neography
|
|
98
98
|
when 204
|
99
99
|
@logger.debug "OK, no content returned" if @log_enabled
|
100
100
|
nil
|
101
|
-
when 400
|
102
|
-
|
101
|
+
when 400..500
|
102
|
+
handle_4xx_500_response(code, body)
|
103
103
|
nil
|
104
104
|
end
|
105
105
|
end
|
106
106
|
|
107
|
-
def
|
107
|
+
def handle_4xx_500_response(code, body)
|
108
108
|
parsed_body = JSON.parse(body)
|
109
109
|
message = parsed_body["message"]
|
110
110
|
stacktrace = parsed_body["stacktrace"]
|
data/lib/neography/rest/batch.rb
CHANGED
@@ -117,7 +117,7 @@ module Neography
|
|
117
117
|
delete Relationships.base_path(:id => get_id(id))
|
118
118
|
end
|
119
119
|
|
120
|
-
def create_relationship(type, from, to, data)
|
120
|
+
def create_relationship(type, from, to, data = nil)
|
121
121
|
post build_node_uri(from) + "/relationships" do
|
122
122
|
{
|
123
123
|
:to => build_node_uri(to),
|
data/lib/neography/version.rb
CHANGED
@@ -134,6 +134,16 @@ describe Neography::Rest do
|
|
134
134
|
batch_result.first["body"]["self"].should == new_relationship["self"]
|
135
135
|
end
|
136
136
|
|
137
|
+
it "can create a single relationship without properties" do
|
138
|
+
node1 = @neo.create_node
|
139
|
+
node2 = @neo.create_node
|
140
|
+
batch_result = @neo.batch [:create_relationship, "friends", node1, node2]
|
141
|
+
batch_result.first["body"]["type"].should == "friends"
|
142
|
+
batch_result.first["body"]["data"]["since"].should be_nil
|
143
|
+
batch_result.first["body"]["start"].split('/').last.should == node1["self"].split('/').last
|
144
|
+
batch_result.first["body"]["end"].split('/').last.should == node2["self"].split('/').last
|
145
|
+
end
|
146
|
+
|
137
147
|
it "can create a single relationship" do
|
138
148
|
node1 = @neo.create_node
|
139
149
|
node2 = @neo.create_node
|
@@ -62,6 +62,15 @@ describe Neography::Rest do
|
|
62
62
|
existing_node["data"][0][0]["self"].split('/').last.should == id
|
63
63
|
end
|
64
64
|
|
65
|
+
it "can delete everything but start node" do
|
66
|
+
@neo.execute_query("START n=node(*) MATCH n-[r?]-() WHERE ID(n) <> 0 DELETE n,r")
|
67
|
+
expect {
|
68
|
+
@neo.execute_query("start n=node({id}) return n", {:id => 1})
|
69
|
+
}.to raise_error(Neography::BadInputException)
|
70
|
+
root_node = @neo.execute_query("start n=node({id}) return n", {:id => 0})
|
71
|
+
root_node.should_not be_nil
|
72
|
+
end
|
73
|
+
|
65
74
|
it "throws an error for an invalid query" do
|
66
75
|
expect {
|
67
76
|
@neo.execute_query("this is not a query")
|
@@ -196,8 +196,15 @@ module Neography
|
|
196
196
|
}.to raise_error NeographyError
|
197
197
|
end
|
198
198
|
|
199
|
-
|
199
|
+
it "raises BadInputException" do
|
200
|
+
response = error_response(code: 500, message: "a message", exception: "JsonParseException")
|
201
|
+
HTTParty.stub(:get).and_return(response)
|
202
|
+
expect {
|
203
|
+
connection.get("/foo/bar")
|
204
|
+
}.to raise_error NeographyError
|
205
|
+
end
|
200
206
|
|
207
|
+
end
|
201
208
|
end
|
202
209
|
end
|
203
210
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: neography
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-10
|
12
|
+
date: 2012-11-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|