Sha256: 73b0a896b15f7c87eafeb7828308553bb33e2bf3230671952122caae5e1f8edd

Contents?: true

Size: 1.08 KB

Versions: 1

Compression:

Stored size: 1.08 KB

Contents

require 'spec_helper_integration'

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

    let(:owner) { mock :owner, :id => 8900 }

    subject do
      CodeRequest.new(pre_auth, owner)
    end

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

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

    it 'does not create grant when not authorizable' do
      pre_auth.stub :authorizable? => false
      expect do
        subject.authorize
      end.to_not change { Doorkeeper::AccessGrant.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

1 entries across 1 versions & 1 rubygems

Version Path
couchkeeper-0.6.7 spec/lib/oauth/code_request_spec.rb