diff --git a/lib/oauth2/access_token.rb b/lib/oauth2/access_token.rb index e320c8cd..38004797 100644 --- a/lib/oauth2/access_token.rb +++ b/lib/oauth2/access_token.rb @@ -44,6 +44,7 @@ def initialize(client, token, opts={}) end @expires_in ||= opts.delete('expires') @expires_in &&= @expires_in.to_i + @expires_at &&= @expires_at.to_i @expires_at ||= Time.now.to_i + @expires_in if @expires_in @options = {:mode => opts.delete(:mode) || :header, :header_format => opts.delete(:header_format) || 'Bearer %s', diff --git a/lib/oauth2/version.rb b/lib/oauth2/version.rb index ea921c7e..dc5ecd5e 100644 --- a/lib/oauth2/version.rb +++ b/lib/oauth2/version.rb @@ -2,7 +2,7 @@ module OAuth2 class Version MAJOR = 0 unless defined? MAJOR MINOR = 8 unless defined? MINOR - PATCH = 0 unless defined? PATCH + PATCH = 1 unless defined? PATCH PRE = nil unless defined? PRE class << self diff --git a/spec/oauth2/access_token_spec.rb b/spec/oauth2/access_token_spec.rb index aa80b823..637dc9a9 100644 --- a/spec/oauth2/access_token_spec.rb +++ b/spec/oauth2/access_token_spec.rb @@ -59,6 +59,13 @@ def assert_initialized_token(target) target.options[:header_format].should == 'Bearer %' target.options[:mode].should == :body end + + it "initializes with a string expires_at" do + hash = {:access_token => token, :expires_at => '1361396829', 'foo' => 'bar'} + target = AccessToken.from_hash(client, hash) + assert_initialized_token(target) + expect(target.expires_at).to be_a(Integer) + end end describe '#request' do