neography 1.1.3 → 1.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.travis.yml +1 -1
- data/lib/neography/rest.rb +8 -0
- data/lib/neography/rest/indexes.rb +3 -0
- data/lib/neography/version.rb +1 -1
- data/spec/integration/rest_index_spec.rb +26 -0
- data/spec/spec_helper.rb +1 -1
- data/spec/unit/connection_spec.rb +7 -7
- data/spec/unit/node_spec.rb +2 -2
- data/spec/unit/properties_spec.rb +1 -1
- data/spec/unit/relationship_spec.rb +4 -4
- data/spec/unit/rest/batch_spec.rb +1 -1
- data/spec/unit/rest/clean_spec.rb +1 -1
- data/spec/unit/rest/cypher_spec.rb +1 -1
- data/spec/unit/rest/extensions_spec.rb +1 -1
- data/spec/unit/rest/gremlin_spec.rb +1 -1
- data/spec/unit/rest/labels_spec.rb +1 -1
- data/spec/unit/rest/node_auto_indexes_spec.rb +1 -1
- data/spec/unit/rest/node_indexes_spec.rb +6 -1
- data/spec/unit/rest/node_paths_spec.rb +1 -1
- data/spec/unit/rest/node_properties_spec.rb +1 -1
- data/spec/unit/rest/node_relationships_spec.rb +1 -1
- data/spec/unit/rest/node_traversal_spec.rb +1 -1
- data/spec/unit/rest/nodes_spec.rb +2 -2
- data/spec/unit/rest/relationship_auto_indexes_spec.rb +1 -1
- data/spec/unit/rest/relationship_indexes_spec.rb +5 -1
- data/spec/unit/rest/relationship_properties_spec.rb +1 -1
- data/spec/unit/rest/relationship_types_spec.rb +1 -1
- data/spec/unit/rest/relationships_spec.rb +1 -1
- data/spec/unit/rest/schema_index_spec.rb +1 -1
- data/spec/unit/rest/transactions_spec.rb +1 -1
- metadata +1 -1
data/.travis.yml
CHANGED
data/lib/neography/rest.rb
CHANGED
@@ -299,6 +299,10 @@ module Neography
|
|
299
299
|
@node_indexes.find(index, key_or_query, value)
|
300
300
|
end
|
301
301
|
|
302
|
+
def drop_node_index(index)
|
303
|
+
@node_indexes.drop(index)
|
304
|
+
end
|
305
|
+
|
302
306
|
# auto node indexes
|
303
307
|
|
304
308
|
def get_node_auto_index(key, value)
|
@@ -362,6 +366,10 @@ module Neography
|
|
362
366
|
def find_relationship_index(index, key_or_query, value = nil)
|
363
367
|
@relationship_indexes.find(index, key_or_query, value)
|
364
368
|
end
|
369
|
+
|
370
|
+
def drop_relationship_index(index)
|
371
|
+
@relationship_indexes.drop(index)
|
372
|
+
end
|
365
373
|
|
366
374
|
# relationship auto indexes
|
367
375
|
|
data/lib/neography/version.rb
CHANGED
@@ -439,4 +439,30 @@ describe Neography::Rest do
|
|
439
439
|
|
440
440
|
end
|
441
441
|
|
442
|
+
describe "drop index" do
|
443
|
+
it "can drop a node index" do
|
444
|
+
new_node = @neo.create_node
|
445
|
+
key = generate_text(6)
|
446
|
+
value = generate_text
|
447
|
+
@neo.add_node_to_index("test_node_index", key, value, new_node)
|
448
|
+
new_index = @neo.get_node_index("test_node_index", key, value)
|
449
|
+
new_index.should_not be_nil
|
450
|
+
@neo.drop_node_index("test_node_index")
|
451
|
+
expect { @neo.get_node_index("test_node_index", key, value) }.to raise_error Neography::NotFoundException
|
452
|
+
end
|
453
|
+
|
454
|
+
it "can get a relationship index" do
|
455
|
+
new_node1 = @neo.create_node
|
456
|
+
new_node2 = @neo.create_node
|
457
|
+
new_relationship = @neo.create_relationship("friends", new_node1, new_node2)
|
458
|
+
key = generate_text(6)
|
459
|
+
value = generate_text
|
460
|
+
@neo.add_relationship_to_index("test_relationship_index", key, value, new_relationship)
|
461
|
+
new_index = @neo.get_relationship_index("test_relationship_index", key, value)
|
462
|
+
new_index.should_not be_nil
|
463
|
+
@neo.drop_relationship_index("test_relationship_index")
|
464
|
+
expect { @neo.get_relationship_index("test_relationship_index", key, value) }.to raise_error Neography::NotFoundException
|
465
|
+
end
|
466
|
+
end
|
467
|
+
|
442
468
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -78,22 +78,22 @@ module Neography
|
|
78
78
|
context "requests" do
|
79
79
|
|
80
80
|
it "does a GET request" do
|
81
|
-
connection.client.should_receive(:get).with("http://localhost:7474/db/data/foo/bar", nil, nil) {
|
81
|
+
connection.client.should_receive(:get).with("http://localhost:7474/db/data/foo/bar", nil, nil) { double.as_null_object }
|
82
82
|
connection.get("/foo/bar")
|
83
83
|
end
|
84
84
|
|
85
85
|
it "does a POST request" do
|
86
|
-
connection.client.should_receive(:post).with("http://localhost:7474/db/data/foo/bar", nil, nil) {
|
86
|
+
connection.client.should_receive(:post).with("http://localhost:7474/db/data/foo/bar", nil, nil) { double.as_null_object }
|
87
87
|
connection.post("/foo/bar")
|
88
88
|
end
|
89
89
|
|
90
90
|
it "does a PUT request" do
|
91
|
-
connection.client.should_receive(:put).with("http://localhost:7474/db/data/foo/bar", nil, nil) {
|
91
|
+
connection.client.should_receive(:put).with("http://localhost:7474/db/data/foo/bar", nil, nil) { double.as_null_object }
|
92
92
|
connection.put("/foo/bar")
|
93
93
|
end
|
94
94
|
|
95
95
|
it "does a DELETE request" do
|
96
|
-
connection.client.should_receive(:delete).with("http://localhost:7474/db/data/foo/bar", nil, nil) {
|
96
|
+
connection.client.should_receive(:delete).with("http://localhost:7474/db/data/foo/bar", nil, nil) { double.as_null_object }
|
97
97
|
connection.delete("/foo/bar")
|
98
98
|
end
|
99
99
|
|
@@ -110,11 +110,11 @@ module Neography
|
|
110
110
|
connection.client.should_receive(:set_auth).with(
|
111
111
|
"http://localhost:7474/db/data/foo/bar",
|
112
112
|
"foo",
|
113
|
-
"bar") {
|
113
|
+
"bar") { double.as_null_object }
|
114
114
|
|
115
115
|
connection.client.should_receive(:get).with(
|
116
116
|
"http://localhost:7474/db/data/foo/bar", nil, nil
|
117
|
-
) {
|
117
|
+
) { double.as_null_object }
|
118
118
|
|
119
119
|
connection.get("/foo/bar")
|
120
120
|
end
|
@@ -124,7 +124,7 @@ module Neography
|
|
124
124
|
connection.client.should_receive(:get).with(
|
125
125
|
"http://localhost:7474/db/data/foo/bar",
|
126
126
|
nil, { "User-Agent" => "Neography/#{Neography::VERSION}", "X-Stream"=>true}
|
127
|
-
) {
|
127
|
+
) { double.as_null_object }
|
128
128
|
|
129
129
|
connection.get("/foo/bar", :headers => {})
|
130
130
|
end
|
data/spec/unit/node_spec.rb
CHANGED
@@ -7,7 +7,7 @@ module Neography
|
|
7
7
|
context "no explicit server" do
|
8
8
|
|
9
9
|
before do
|
10
|
-
@db =
|
10
|
+
@db = double(Neography::Rest, :is_a? => true).as_null_object
|
11
11
|
Rest.stub(:new) { @db }
|
12
12
|
end
|
13
13
|
|
@@ -55,7 +55,7 @@ module Neography
|
|
55
55
|
|
56
56
|
before do
|
57
57
|
# stub out actual connections
|
58
|
-
@db =
|
58
|
+
@db = double(Rest).as_null_object
|
59
59
|
Rest.stub(:new) { @db }
|
60
60
|
end
|
61
61
|
|
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
module Neography
|
4
4
|
describe Relationship do
|
5
5
|
|
6
|
-
let(:db) {
|
6
|
+
let(:db) { double(Rest).as_null_object }
|
7
7
|
let(:relationship_hash) do
|
8
8
|
{
|
9
9
|
"self" => "0",
|
@@ -13,8 +13,8 @@ module Neography
|
|
13
13
|
}
|
14
14
|
end
|
15
15
|
|
16
|
-
let(:from) {
|
17
|
-
let(:to) {
|
16
|
+
let(:from) { double(:neo_server => db) }
|
17
|
+
let(:to) { double(:neo_server => db) }
|
18
18
|
let(:props) { { :foo => "bar" } }
|
19
19
|
|
20
20
|
describe "::create" do
|
@@ -40,7 +40,7 @@ module Neography
|
|
40
40
|
|
41
41
|
before do
|
42
42
|
# stub out actual connections
|
43
|
-
@db =
|
43
|
+
@db = double(Rest).as_null_object
|
44
44
|
Rest.stub(:new) { @db }
|
45
45
|
end
|
46
46
|
|
@@ -4,7 +4,7 @@ module Neography
|
|
4
4
|
class Rest
|
5
5
|
describe Batch do
|
6
6
|
|
7
|
-
let(:connection) {
|
7
|
+
let(:connection) { double(:gremlin_path => "/gremlin", :cypher_path => "/cypher") }
|
8
8
|
subject { Batch.new(connection) }
|
9
9
|
|
10
10
|
it "gets nodes" do
|
@@ -4,7 +4,7 @@ module Neography
|
|
4
4
|
class Rest
|
5
5
|
describe NodeIndexes do
|
6
6
|
|
7
|
-
let(:connection) {
|
7
|
+
let(:connection) { double(:configuration => "http://configuration") }
|
8
8
|
subject { NodeIndexes.new(connection) }
|
9
9
|
|
10
10
|
it "lists all indexes" do
|
@@ -131,6 +131,11 @@ module Neography
|
|
131
131
|
subject.remove_by_value("some_index", "42", "some_key", "some_value")
|
132
132
|
end
|
133
133
|
|
134
|
+
it "drops an index" do
|
135
|
+
connection.should_receive(:delete).with("/index/node/some_index")
|
136
|
+
subject.drop("some_index")
|
137
|
+
end
|
138
|
+
|
134
139
|
end
|
135
140
|
end
|
136
141
|
end
|
@@ -4,7 +4,7 @@ module Neography
|
|
4
4
|
class Rest
|
5
5
|
describe NodePaths do
|
6
6
|
|
7
|
-
let(:connection) {
|
7
|
+
let(:connection) { double(:configuration => "http://configuration") }
|
8
8
|
subject { NodePaths.new(connection) }
|
9
9
|
|
10
10
|
it "gets a shortest path between two nodes" do
|
@@ -4,7 +4,7 @@ module Neography
|
|
4
4
|
class Rest
|
5
5
|
describe NodeRelationships do
|
6
6
|
|
7
|
-
let(:connection) {
|
7
|
+
let(:connection) { double(:configuration => "http://configuration") }
|
8
8
|
subject { NodeRelationships.new(connection) }
|
9
9
|
|
10
10
|
it "creates a relationship" do
|
@@ -4,7 +4,7 @@ module Neography
|
|
4
4
|
class Rest
|
5
5
|
describe Nodes do
|
6
6
|
|
7
|
-
let(:connection) {
|
7
|
+
let(:connection) { double }
|
8
8
|
subject { Nodes.new(connection) }
|
9
9
|
|
10
10
|
context "get nodes" do
|
@@ -141,7 +141,7 @@ module Neography
|
|
141
141
|
|
142
142
|
context "#create_multiple_threaded" do
|
143
143
|
|
144
|
-
let(:connection) {
|
144
|
+
let(:connection) { double(:max_threads => 2) }
|
145
145
|
|
146
146
|
it "creates multiple with attributes" do
|
147
147
|
options1 = {
|
@@ -4,7 +4,7 @@ module Neography
|
|
4
4
|
class Rest
|
5
5
|
describe RelationshipIndexes do
|
6
6
|
|
7
|
-
let(:connection) {
|
7
|
+
let(:connection) { double(:configuration => "http://configuration") }
|
8
8
|
subject { RelationshipIndexes.new(connection) }
|
9
9
|
|
10
10
|
it "lists all indexes" do
|
@@ -123,6 +123,10 @@ module Neography
|
|
123
123
|
subject.remove_by_value("some_index", "42", "some_key", "some_value")
|
124
124
|
end
|
125
125
|
|
126
|
+
it "drops an index" do
|
127
|
+
connection.should_receive(:delete).with("/index/relationship/some_index")
|
128
|
+
subject.drop("some_index")
|
129
|
+
end
|
126
130
|
end
|
127
131
|
end
|
128
132
|
end
|
@@ -4,7 +4,7 @@ module Neography
|
|
4
4
|
class Rest
|
5
5
|
describe RelationshipTypes do
|
6
6
|
|
7
|
-
let(:connection) {
|
7
|
+
let(:connection) { double(:configuration => "http://configuration") }
|
8
8
|
subject { RelationshipTypes.new(connection) }
|
9
9
|
|
10
10
|
it "lists all relationship types" do
|
@@ -4,7 +4,7 @@ module Neography
|
|
4
4
|
class Rest
|
5
5
|
describe SchemaIndexes do
|
6
6
|
|
7
|
-
let(:connection) {
|
7
|
+
let(:connection) { double(:configuration => "http://configuration") }
|
8
8
|
subject { SchemaIndexes.new(connection) }
|
9
9
|
|
10
10
|
it "create schema indexes" do
|
@@ -4,7 +4,7 @@ module Neography
|
|
4
4
|
class Rest
|
5
5
|
describe Transactions do
|
6
6
|
|
7
|
-
let(:connection) {
|
7
|
+
let(:connection) { double(:configuration => "http://configuration") }
|
8
8
|
subject { Transactions.new(connection) }
|
9
9
|
|
10
10
|
it "can create new transactions" do
|