Sha256: 5992fe13a4f64d72c2c7878ae9a57d755f24b6865b2ed998044d51a0c740fca7

Contents?: true

Size: 947 Bytes

Versions: 2

Compression:

Stored size: 947 Bytes

Contents

require 'spec_helper_integration'

describe Doorkeeper::TokensController do
  describe 'when authorization has succeeded' do
    let :token do
      double(:token, authorize: true)
    end

    before do
      allow(controller).to receive(:token) { token }
    end

    it 'returns the authorization' do
      pending 'verify need of these specs'
      expect(token).to receive(:authorization)
      post :create
    end
  end

  describe 'when authorization has failed' do
    let :token do
      double(:token, authorize: false)
    end

    before do
      allow(controller).to receive(:token) { token }
    end

    it 'returns the error response' do
      pending 'verify need of these specs'
      allow(token).to receive(:error_response).and_return(double(to_json: [], status: :unauthorized))
      post :create
      expect(response.status).to eq 401
      expect(response.headers['WWW-Authenticate']).to match(/Bearer/)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
doorkeeper-1.3.0 spec/controllers/tokens_controller_spec.rb
doorkeeper-1.2.0 spec/controllers/tokens_controller_spec.rb