Sha256: e6dcff3180ceba0b2c3606494dde651acd63ca4734602fcc759994ad4878e1d5

Contents?: true

Size: 1.08 KB

Versions: 40

Compression:

Stored size: 1.08 KB

Contents

require 'spec_helper_integration'

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

    let(:owner) { double :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
      expect(subject.authorize).to be_a(CodeResponse)
    end

    it 'does not create grant when not authorizable' do
      allow(pre_auth).to receive(:authorizable?).and_return(false)
      expect do
        subject.authorize
      end.to_not change { Doorkeeper::AccessGrant.count }
    end

    it 'returns a error response' do
      allow(pre_auth).to receive(:authorizable?).and_return(false)
      expect(subject.authorize).to be_a(ErrorResponse)
    end
  end
end

Version data entries

40 entries across 40 versions & 3 rubygems

Version Path
doorkeeper-3.0.0.rc2 spec/lib/oauth/code_request_spec.rb
doorkeeper-3.0.0.rc1 spec/lib/oauth/code_request_spec.rb
doorkeeper-2.2.1 spec/lib/oauth/code_request_spec.rb
doorkeeper-2.2.0 spec/lib/oauth/code_request_spec.rb
doorkeeper-2.1.4 spec/lib/oauth/code_request_spec.rb
doorkeeper-1.4.2 spec/lib/oauth/code_request_spec.rb
doorkeeper-2.1.3 spec/lib/oauth/code_request_spec.rb
doorkeeper-2.1.2 spec/lib/oauth/code_request_spec.rb
doorkeeper-2.1.1 spec/lib/oauth/code_request_spec.rb
doorkeeper-2.1.0 spec/lib/oauth/code_request_spec.rb
doorkeeper-2.0.1 spec/lib/oauth/code_request_spec.rb
doorkeeper-1.4.1 spec/lib/oauth/code_request_spec.rb
doorkeeper-2.0.0 spec/lib/oauth/code_request_spec.rb
doorkeeper-2.0.0.rc3 spec/lib/oauth/code_request_spec.rb
doorkeeper-2.0.0.rc2 spec/lib/oauth/code_request_spec.rb
doorkeeper-2.0.0.alpha1 spec/lib/oauth/code_request_spec.rb
doorkeeper-1.4.0 spec/lib/oauth/code_request_spec.rb
doorkeeper-1.3.1 spec/lib/oauth/code_request_spec.rb
doorkeeper-1.3.0 spec/lib/oauth/code_request_spec.rb
doorkeeper-1.2.0 spec/lib/oauth/code_request_spec.rb