diff --git a/lib/neography/rest.rb b/lib/neography/rest.rb index c5c555a..71e91e4 100644 --- a/lib/neography/rest.rb +++ b/lib/neography/rest.rb @@ -490,6 +490,12 @@ def clean_database(sanity_check = "not_really") false end end + + def merge_options(options) + merged_options = options.merge!(@authentication).merge!(@parser) + merged_options[:headers].merge!(@user_agent) if merged_options[:headers] + merged_options + end private @@ -571,12 +577,6 @@ def evaluate_response(response) end end - def merge_options(options) - merged_options = options.merge!(@authentication).merge!(@parser) - merged_options[:headers].merge!(@user_agent) if merged_options[:headers] - merged_options - end - def get(path,options={}) evaluate_response(HTTParty.get(configuration + URI.encode(path), merge_options(options))) end diff --git a/spec/integration/rest_header_spec.rb b/spec/integration/rest_header_spec.rb new file mode 100644 index 0000000..473d294 --- /dev/null +++ b/spec/integration/rest_header_spec.rb @@ -0,0 +1,20 @@ +require File.join(File.dirname(__FILE__), '..', 'spec_helper') + +describe Neography::Rest do + before(:each) do + @neo = Neography::Rest.new + end + + it "should not add a content-type header if there's no existing headers" do + @neo.merge_options({}).should == {:parser => OjParser} + end + + it "should add a content type if there's existing headers" do + @neo.merge_options({:headers => {'Content-Type' => 'foo/bar'}}).should == + {:headers => {'Content-Type' => "foo/bar", + "User-Agent" => "Neography/#{Neography::VERSION}"}, + :parser => OjParser} + end + + +end