public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] gentoo-x86 commit in dev-ruby/oauth2/files: oauth2-0.0.9-gentoo.patch
@ 2010-06-19 12:34 Diego Petteno (flameeyes)
  0 siblings, 0 replies; only message in thread
From: Diego Petteno (flameeyes) @ 2010-06-19 12:34 UTC (permalink / raw
  To: gentoo-commits

flameeyes    10/06/19 12:34:34

  Added:                oauth2-0.0.9-gentoo.patch
  Log:
  Version bump, new ebuild needs multi_json (and a fixed one) and is further fixed.
  (Portage version: 2.2_rc67/cvs/Linux x86_64)

Revision  Changes    Path
1.1                  dev-ruby/oauth2/files/oauth2-0.0.9-gentoo.patch

file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-ruby/oauth2/files/oauth2-0.0.9-gentoo.patch?rev=1.1&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-ruby/oauth2/files/oauth2-0.0.9-gentoo.patch?rev=1.1&content-type=text/plain

Index: oauth2-0.0.9-gentoo.patch
===================================================================
diff --git a/Rakefile b/Rakefile
index e4b0361..983d568 100644
--- a/Rakefile
+++ b/Rakefile
@@ -16,10 +16,13 @@ begin
     # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
   end
   Jeweler::GemcutterTasks.new
+
+  task :spec => :check_dependencies
 rescue LoadError
   puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
 end
 
+begin
 require 'spec/rake/spectask'
 Spec::Rake::SpecTask.new(:spec) do |spec|
   spec.libs << 'lib' << 'spec'
@@ -32,9 +35,10 @@ Spec::Rake::SpecTask.new(:rcov) do |spec|
   spec.rcov = true
 end
 
-task :spec => :check_dependencies
-
 task :default => :spec
+rescue LoadError
+  puts "RSpec (or a dependency) not available. Install it with: gem install rspec"
+end
 
 require 'rake/rdoctask'
 Rake::RDocTask.new do |rdoc|
diff --git a/lib/oauth2/strategy/web_server.rb b/lib/oauth2/strategy/web_server.rb
index f8aa562..25bd5a9 100644
--- a/lib/oauth2/strategy/web_server.rb
+++ b/lib/oauth2/strategy/web_server.rb
@@ -13,7 +13,14 @@ module OAuth2
       # endpoints.
       def get_access_token(code, options = {})
         response = @client.request(:post, @client.access_token_url, access_token_params(code, options))
-        params   = MultiJson.decode(response) rescue Rack::Utils.parse_query(response)
+
+        params   = MultiJson.decode(response) rescue nil
+        # the ActiveSupport JSON parser won't cause an exception when
+        # given a formencoded string, so make sure that it was
+        # actually parsed in an Hash. This covers even the case where
+        # it caused an exception since it'll still be nil.
+        params   = Rack::Utils.parse_query(response) unless params.is_a? Hash
+
         access   = params['access_token']
         refresh  = params['refresh_token']
         expires_in = params['expires_in']
diff --git a/spec/oauth2/strategy/web_server_spec.rb b/spec/oauth2/strategy/web_server_spec.rb
index aee0b76..14c5008 100644
--- a/spec/oauth2/strategy/web_server_spec.rb
+++ b/spec/oauth2/strategy/web_server_spec.rb
@@ -34,8 +34,8 @@ describe OAuth2::Strategy::WebServer do
     end
   end
 
-  describe "#get_access_token" do
     %w(json formencoded).each do |mode|
+    describe "#get_access_token (#{mode})" do
       before do
         @mode = mode
         @access = subject.get_access_token('sushi')






^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2010-06-19 12:34 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-19 12:34 [gentoo-commits] gentoo-x86 commit in dev-ruby/oauth2/files: oauth2-0.0.9-gentoo.patch Diego Petteno (flameeyes)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox