diff --git a/lib/neography/config.rb b/lib/neography/config.rb index f76fed9..7334a9f 100644 --- a/lib/neography/config.rb +++ b/lib/neography/config.rb @@ -6,7 +6,7 @@ class Config :log_file, :log_enabled, :slow_log_threshold, :max_threads, :authentication, :username, :password, - :parser + :parser, :max_execution_time def initialize set_defaults @@ -27,7 +27,8 @@ def to_hash :authentication => @authentication, :username => @username, :password => @password, - :parser => @parser + :parser => @parser, + :max_execution_time => @max_execution_time } end @@ -48,6 +49,7 @@ def set_defaults @username = nil @password = nil @parser = MultiJsonParser + @max_execution_time = 6000 end end diff --git a/lib/neography/connection.rb b/lib/neography/connection.rb index 17da182..bdae7a4 100644 --- a/lib/neography/connection.rb +++ b/lib/neography/connection.rb @@ -36,6 +36,7 @@ def merge_options(options) merged_options = options.merge!(@authentication) merged_options[:headers].merge!(@user_agent) if merged_options[:headers] merged_options[:headers].merge!('X-Stream' => true) if merged_options[:headers] + merged_options[:headers].merge!(@max_execution_time) if merged_options[:headers] merged_options end @@ -88,6 +89,7 @@ def save_local_configuration(config) @max_threads = config[:max_threads] @parser = config[:parser] + @max_execution_time = { 'max-execution-time' => config[:max_execution_time] } @user_agent = { "User-Agent" => USER_AGENT } @authentication = {} diff --git a/spec/integration/rest_header_spec.rb b/spec/integration/rest_header_spec.rb index c88188a..8328bfd 100644 --- a/spec/integration/rest_header_spec.rb +++ b/spec/integration/rest_header_spec.rb @@ -8,7 +8,7 @@ it "should add a content type if there's existing headers" do subject.merge_options({:headers => {'Content-Type' => 'foo/bar'}})[:headers].should == - {'Content-Type' => "foo/bar", "User-Agent" => "Neography/#{Neography::VERSION}" , "X-Stream"=>true} + {'Content-Type' => "foo/bar", "User-Agent" => "Neography/#{Neography::VERSION}" , "X-Stream"=>true, "max-execution-time"=>6000} end end diff --git a/spec/unit/config_spec.rb b/spec/unit/config_spec.rb index b8676fb..9e38b54 100644 --- a/spec/unit/config_spec.rb +++ b/spec/unit/config_spec.rb @@ -21,6 +21,7 @@ module Neography its(:username) { should == nil } its(:password) { should == nil } its(:parser) { should == MultiJsonParser} + its(:max_execution_time) { should == 6000 } it "has a hash representation" do expected_hash = { @@ -37,7 +38,8 @@ module Neography :authentication => nil, :username => nil, :password => nil, - :parser => MultiJsonParser + :parser => MultiJsonParser, + :max_execution_time => 6000 } config.to_hash.should == expected_hash end diff --git a/spec/unit/connection_spec.rb b/spec/unit/connection_spec.rb index eeb822e..18e50f2 100644 --- a/spec/unit/connection_spec.rb +++ b/spec/unit/connection_spec.rb @@ -125,7 +125,7 @@ module Neography it "adds the User-Agent to the headers" do connection.client.should_receive(:get).with( "http://localhost:7474/db/data/foo/bar", - nil, { "User-Agent" => "Neography/#{Neography::VERSION}", "X-Stream"=>true} + nil, { "User-Agent" => "Neography/#{Neography::VERSION}", "X-Stream"=>true, "max-execution-time"=>6000} ) { double.as_null_object } connection.get("/foo/bar", :headers => {})