Permalink
Browse files

better support for rails3

  • Loading branch information...
pelle authored and quirkey committed Aug 29, 2010
1 parent 4fb9698 commit 7ce26fc214e72d6eedcf02a29d5e68ffbcd8eeb5
Showing with 20 additions and 9 deletions.
  1. +1 −1 Rakefile
  2. +19 −8 lib/oauth/client/action_controller_request.rb
View
@@ -12,7 +12,7 @@ begin
s.description = "OAuth Core Ruby implementation"
s.summary = s.description
s.rubyforge_project = %q{oauth}
- s.add_development_dependency(%q<actionpack>, ["2.3.8"])
+ s.add_development_dependency(%q<actionpack>, [">=2.3.8"])
s.add_development_dependency(%q<rack>, [">= 1.0.0"])
s.add_development_dependency(%q<mocha>, [">= 0.9.8"])
s.add_development_dependency(%q<typhoeus>, [">= 0.1.13"])
@@ -1,15 +1,26 @@
require 'oauth/client/helper'
-require 'oauth/request_proxy/action_controller_request'
-require 'action_controller/test_process'
+if defined? ActionDispatch
+ require 'oauth/request_proxy/rack_request'
+ require 'action_dispatch/testing/test_process'
+else
+ require 'oauth/request_proxy/action_controller_request'
+ require 'action_controller/test_process'
+end
module ActionController
class Base
- def process_with_oauth(request, response=nil)
- request.apply_oauth! if request.respond_to?(:apply_oauth!)
- process_without_oauth(request, response)
+ if defined? ActionDispatch
+ def process_with_new_base_test(request, response=nil)
+ request.apply_oauth! if request.respond_to?(:apply_oauth!)
+ super(request, response)
+ end
+ else
+ def process_with_oauth(request, response=nil)
+ request.apply_oauth! if request.respond_to?(:apply_oauth!)
+ process_without_oauth(request, response)
+ end
+ alias_method_chain :process, :oauth
end
-
- alias_method_chain :process, :oauth
end
class TestRequest
@@ -33,7 +44,7 @@ def configure_oauth(consumer = nil, token = nil, options = {})
def apply_oauth!
return unless ActionController::TestRequest.use_oauth? && @oauth_options
- @oauth_helper = OAuth::Client::Helper.new(self, @oauth_options.merge(:request_uri => request_uri))
+ @oauth_helper = OAuth::Client::Helper.new(self, @oauth_options.merge(:request_uri => (respond_to?(:fullpath) ? fullpath : request_uri)))
@oauth_helper.amend_user_agent_header(env)
self.send("set_oauth_#{@oauth_options[:scheme]}")

0 comments on commit 7ce26fc

Please sign in to comment.