-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a547370
commit ea658b0
Showing
5 changed files
with
112 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
script: "bundle exec rake neo4j:install['enterprise','1.9'] neo4j:start spec --trace" | ||
script: "bundle exec rake neo4j:install['enterprise','2.0.0-M03'] neo4j:start spec --trace" | ||
language: ruby | ||
rvm: | ||
- 1.9.3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
module Neography | ||
class Rest | ||
class SchemaIndexes | ||
extend Neography::Rest::Paths | ||
include Neography::Rest::Helpers | ||
|
||
add_path :base, "/schema/index/:label" | ||
add_path :drop, "/schema/index/:label/:index" | ||
|
||
def initialize(connection) | ||
@connection = connection | ||
end | ||
|
||
def list(label) | ||
@connection.get(base_path(:label => label)) | ||
end | ||
|
||
def drop(label, index) | ||
@connection.delete(drop_path(:label => label, :index => index)) | ||
end | ||
|
||
def create(label, keys = []) | ||
options = { | ||
:body => ( | ||
{ :property_keys => keys | ||
} | ||
).to_json, | ||
:headers => json_content_type | ||
} | ||
@connection.post(base_path(:label => label), options) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
require 'spec_helper' | ||
|
||
describe Neography::Rest do | ||
before(:each) do | ||
@neo = Neography::Rest.new | ||
end | ||
|
||
describe "create a schema index" do | ||
it "can create a schema index" do | ||
si = @neo.create_schema_index("person", ["name"]) | ||
si.should_not be_nil | ||
si["property-keys"].should include("name") | ||
end | ||
|
||
end | ||
|
||
describe "list schema indexes" do | ||
it "can get a listing of node indexes" do | ||
si = @neo.get_schema_index("person") | ||
si.should_not be_nil | ||
si.first["label"].should include("person") | ||
si.first["property-keys"].should include("name") | ||
end | ||
end | ||
|
||
describe "drop schema indexes" do | ||
it "can drop an existing schema index" do | ||
si = @neo.delete_schema_index("person", "name") | ||
si.should be_nil | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
require 'spec_helper' | ||
|
||
module Neography | ||
class Rest | ||
describe SchemaIndexes do | ||
|
||
let(:connection) { stub(:configuration => "http://configuration") } | ||
subject { SchemaIndexes.new(connection) } | ||
|
||
it "create schema indexes" do | ||
options = { | ||
:body => '{"property_keys":["name"]}', | ||
:headers => json_content_type | ||
} | ||
connection.should_receive(:post).with("/schema/index/person", options) | ||
subject.create("person", ["name"]) | ||
end | ||
|
||
it "get schema indexes" do | ||
connection.should_receive(:get).with("/schema/index/person") | ||
subject.list("person") | ||
end | ||
|
||
it "delete schema indexes" do | ||
connection.should_receive(:delete).with("/schema/index/person/name") | ||
subject.drop("person","name") | ||
end | ||
|
||
end | ||
end | ||
end |