Skip to content

Commit

Permalink
allow unmanaged extensions if they start with unmanaged
Browse files Browse the repository at this point in the history
  • Loading branch information
maxdemarzi committed Jan 21, 2014
1 parent d4aecae commit 8955dda
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 13 deletions.
7 changes: 4 additions & 3 deletions lib/neography/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def configure(protocol, server, port, directory)
end

def configuration
@configuration ||= "#{@protocol}#{@server}:#{@port}#{@directory}/db/data"
@configuration ||= "#{@protocol}#{@server}:#{@port}#{@directory}"
end

def merge_options(options)
Expand All @@ -41,8 +41,9 @@ def merge_options(options)
end

ACTIONS.each do |action|
define_method(action) do |path, options = {}|
query_path = configuration + path
define_method(action) do |path, options = {}|
base = path.start_with?("/unmanaged") ? "" : "/db/data"

This comment has been minimized.

Copy link
@kwent

kwent Jan 30, 2014

Contributor

If my unmanaged endpoint is not beginning by /unmanaged but by /mycustom path endpoint? => 404 errors.

This comment has been minimized.

Copy link
@maxdemarzi

maxdemarzi Jan 31, 2014

Author Owner

yeah, I was being stupid and lazy, I'll fix this.

query_path = configuration + base + path
query_body = merge_options(options)[:body]
log path, query_body do
evaluate_response(@client.send(action.to_sym, query_path, query_body, merge_options(options)[:headers]), path, query_body)
Expand Down
5 changes: 3 additions & 2 deletions spec/integration/index_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,11 @@
end

it "can find a node in an index with brackets" do
key = generate_text(6)
value = "Sen. Roy Blunt [R-MO]"
new_node = Neography::Node.create("name" => value)
new_node.add_to_index("node_test_index", "name", value)
existing_node = Neography::Node.find("node_test_index", "name", value)
new_node.add_to_index(key, "name", value)
existing_node = Neography::Node.find(key, "name", value)
existing_node.name.should == value
end

Expand Down
10 changes: 5 additions & 5 deletions spec/integration/rest_index_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
name = generate_text(6)
new_index = @neo.create_node_index(name)
new_index.should_not be_nil
new_index["template"].should == "#{@neo.configuration}/index/node/#{name}/{key}/{value}"
new_index["template"].should == "#{@neo.configuration}/db/data/index/node/#{name}/{key}/{value}"
new_index["provider"].should == "lucene"
new_index["type"].should == "exact"
end
Expand All @@ -39,7 +39,7 @@
name = generate_text(6)
new_index = @neo.create_node_index(name, "fulltext","lucene")
new_index.should_not be_nil
new_index["template"].should == "#{@neo.configuration}/index/node/#{name}/{key}/{value}"
new_index["template"].should == "#{@neo.configuration}/db/data/index/node/#{name}/{key}/{value}"
new_index["provider"].should == "lucene"
new_index["type"].should == "fulltext"
end
Expand All @@ -48,7 +48,7 @@
name = generate_text(6)
new_index = @neo.create_node_index(name, "fulltext","lucene", extra: 'extra-value')
new_index.should_not be_nil
new_index["template"].should == "#{@neo.configuration}/index/node/#{name}/{key}/{value}"
new_index["template"].should == "#{@neo.configuration}/db/data/index/node/#{name}/{key}/{value}"
new_index["provider"].should == "lucene"
new_index["extra"].should == "extra-value"
new_index["type"].should == "fulltext"
Expand All @@ -58,7 +58,7 @@
name = generate_text(6)
new_index = @neo.create_relationship_index(name)
new_index.should_not be_nil
new_index["template"].should == "#{@neo.configuration}/index/relationship/#{name}/{key}/{value}"
new_index["template"].should == "#{@neo.configuration}/db/data/index/relationship/#{name}/{key}/{value}"
new_index["provider"].should == "lucene"
new_index["type"].should == "exact"
end
Expand All @@ -67,7 +67,7 @@
name = generate_text(6)
new_index = @neo.create_relationship_index(name, "fulltext","lucene")
new_index.should_not be_nil
new_index["template"].should == "#{@neo.configuration}/index/relationship/#{name}/{key}/{value}"
new_index["template"].should == "#{@neo.configuration}/db/data/index/relationship/#{name}/{key}/{value}"
new_index["provider"].should == "lucene"
new_index["type"].should == "fulltext"
end
Expand Down
6 changes: 3 additions & 3 deletions spec/unit/connection_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module Neography
context "defaults" do

it "intializes with defaults" do
connection.configuration.should == "http://localhost:7474/db/data"
connection.configuration.should == "http://localhost:7474"
end

end
Expand Down Expand Up @@ -38,7 +38,7 @@ module Neography
end

it "accepts all options in a hash" do
connection.configuration.should == "https://foobar:4242/dir/db/data"
connection.configuration.should == "https://foobar:4242/dir"

connection.protocol.should == "https://"
connection.server.should == "foobar"
Expand All @@ -65,7 +65,7 @@ module Neography
let(:options) { "https://user:pass@somehost:8585/path" }

it "accepts a string as configuration" do
connection.configuration.should == "https://somehost:8585/path/db/data"
connection.configuration.should == "https://somehost:8585/path"
connection.authentication.should == {
:basic_auth => {
:username => "user",
Expand Down

0 comments on commit 8955dda

Please sign in to comment.