Permalink
Browse files

Merge branch 'master' of github.com:oauth/oauth-ruby

  • Loading branch information...
2 parents e1a11f8 + 1af6de8 commit e4bca718553aa1000c39ffdbf5a12414c569eeea @quirkey quirkey committed Apr 21, 2012
Showing with 32 additions and 0 deletions.
  1. +4 −0 lib/oauth/consumer.rb
  2. +28 −0 test/test_consumer.rb
View
@@ -328,6 +328,10 @@ def create_http_request(http_method, path, *arguments)
data = arguments.shift
end
+ # if the base site contains a path, add it now
+ uri = URI.parse(site)
+ path = uri.path + path if uri.path
+
headers = arguments.first.is_a?(Hash) ? arguments.shift : {}
case http_method
View
@@ -61,6 +61,34 @@ def test_defaults
assert_equal :post,@consumer.http_method
end
+ def test_site_without_path
+ @consumer=OAuth::Consumer.new(
+ "key",
+ "secret",
+ {
+ :site=>"http://twitter.com"
+ })
+ request = stub(:oauth! => nil)
+ http = stub(:request => stub(:to_hash => {}))
+ Net::HTTP::Get.expects(:new).with('/people', {}).returns(request)
+ @consumer.expects(:create_http).returns(http)
+ @consumer.request(:get, '/people', nil, {})
+ end
+
+ def test_site_with_path
+ @consumer=OAuth::Consumer.new(
+ "key",
+ "secret",
+ {
+ :site=>"http://identi.ca/api"
+ })
+ request = stub(:oauth! => nil)
+ http = stub(:request => stub(:to_hash => {}))
+ Net::HTTP::Get.expects(:new).with('/api/people', {}).returns(request)
+ @consumer.expects(:create_http).returns(http)
+ @consumer.request(:get, '/people', nil, {})
+ end
+
def test_override_paths
@consumer=OAuth::Consumer.new(
"key",

0 comments on commit e4bca71

Please sign in to comment.