Skip to content

Commit

Permalink
FbGraph.http_config
Browse files Browse the repository at this point in the history
close nov#151
  • Loading branch information
nov committed Feb 6, 2012
1 parent 9d44819 commit f4a3a39
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 5 deletions.
13 changes: 13 additions & 0 deletions lib/fb_graph.rb
Expand Up @@ -40,6 +40,19 @@ def self.debug(&block)
self.debugging = original
end
self.debugging = false

def self.http_client
_http_client_ = HTTPClient.new(
:agent_name => "FbGraph (#{VERSION})"
)
_http_client_.request_filter << Debugger::RequestFilter.new if debugging?
http_config.try(:call, _http_client_)
_http_client_
end
def self.http_config(&block)
Rack::OAuth2.http_config &block unless Rack::OAuth2.http_config
@@http_config ||= block
end
end

require 'fb_graph/exception'
Expand Down
6 changes: 1 addition & 5 deletions lib/fb_graph/node.rb
Expand Up @@ -65,11 +65,7 @@ def delete(params = {})
end

def http_client
_http_client_ = HTTPClient.new(
:agent_name => "FbGraph (#{VERSION})"
)
_http_client_.request_filter << Debugger::RequestFilter.new if FbGraph.debugging?
_http_client_
FbGraph.http_client
end

private
Expand Down
15 changes: 15 additions & 0 deletions spec/fb_graph_spec.rb
Expand Up @@ -33,4 +33,19 @@
FbGraph.debugging?.should be_true
end
end

describe '.http_client' do
context 'with http_config' do
before do
FbGraph.http_config do |config|
config.ssl_config.verify_mode = OpenSSL::SSL::VERIFY_NONE
end
end
it 'should configure Rack::OAuth2 and FbGraph http_client' do
[Rack::OAuth2, FbGraph].each do |klass|
klass.http_client.ssl_config.verify_mode.should == OpenSSL::SSL::VERIFY_NONE
end
end
end
end
end

0 comments on commit f4a3a39

Please sign in to comment.