Sha256: 1ceba6d154b4b3b96f9c97aaf4323321bd03e62035b89a978ff91baab5bfc793

Contents?: true

Size: 865 Bytes

Versions: 4

Compression:

Stored size: 865 Bytes

Contents

require 'spec_helper'

describe ProtectedController do

  describe 'get :index' do
    with :client
    with :user
    before do
      @token = Devise::Oauth2::AccessToken.create! :client => client, :owner => user
    end
    context 'with valid bearer token in header' do
      before do
        @request.env['HTTP_AUTHORIZATION'] = "Bearer #{@token.token}"
        get :index, :format => 'json'
      end
      it { should respond_with :ok }
    end
    context 'with valid bearer token in query string' do
      before do
        get :index, :access_token => @token.token, :format => 'json'
      end
      it { should respond_with :ok }
    end

    context 'with invalid bearer token in query param' do
      before do
        get :index, :access_token => 'invalid', :format => 'json'
      end
      it { should respond_with :unauthorized }
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
devise_oauth2_rails4-2.1.8 spec/controllers/protected_controller_spec.rb
devise_oauth2_rails4-2.1.7 spec/controllers/protected_controller_spec.rb
devise_oauth2_rails4-2.1.6 spec/controllers/protected_controller_spec.rb
devise_oauth2_rails4-2.1.5 spec/controllers/protected_controller_spec.rb