Sha256: 1e2ac8b3d944830a59e5167f994bba2e6077d1ee830957d6af6d9b293861784c

Contents?: true

Size: 1.05 KB

Versions: 14

Compression:

Stored size: 1.05 KB

Contents

require 'spec_helper_integration'

module Doorkeeper::OAuth
  describe TokenRequest do
    let :pre_auth do
      mock(:pre_auth, {
        :client => mock(:application, :id => 9990),
        :redirect_uri => 'http://tst.com/cb',
        :state => nil,
        :scopes => nil,
        :error => nil,
        :authorizable? => true
      })
    end

    let :owner do
      mock :owner, :id => 7866
    end

    subject do
      TokenRequest.new(pre_auth, owner)
    end

    it 'creates an access token' do
      expect do
        subject.authorize
      end.to change { Doorkeeper::AccessToken.count }.by(1)
    end

    it 'returns a code response' do
      subject.authorize.should be_a(CodeResponse)
    end

    it 'does not create token when not authorizable' do
      pre_auth.stub :authorizable? => false
      expect do
        subject.authorize
      end.to_not change { Doorkeeper::AccessToken.count }
    end

    it 'returns a error response' do
      pre_auth.stub :authorizable? => false
      subject.authorize.should be_a(ErrorResponse)
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
doorkeeper-0.7.4 spec/lib/oauth/token_request_spec.rb
doorkeeper-0.7.3 spec/lib/oauth/token_request_spec.rb
doorkeeper-0.7.2 spec/lib/oauth/token_request_spec.rb
doorkeeper-0.7.1 spec/lib/oauth/token_request_spec.rb
doorkeeper-0.7.0 spec/lib/oauth/token_request_spec.rb
doorkeeper-0.6.7 spec/lib/oauth/token_request_spec.rb
doorkeeper-0.6.6 spec/lib/oauth/token_request_spec.rb
doorkeeper-0.6.5 spec/lib/oauth/token_request_spec.rb
doorkeeper-0.6.4 spec/lib/oauth/token_request_spec.rb
doorkeeper-0.6.3 spec/lib/oauth/token_request_spec.rb
doorkeeper-0.6.2 spec/lib/oauth/token_request_spec.rb
doorkeeper-0.6.1 spec/lib/oauth/token_request_spec.rb
doorkeeper-0.6.0 spec/lib/oauth/token_request_spec.rb
doorkeeper-0.6.0.rc1 spec/lib/oauth/token_request_spec.rb