Sha256: dd4936a3cdec8d75f9421383c7161d6f4b7ce1d4a2f44feba410d09df58540d9

Contents?: true

Size: 1.33 KB

Versions: 19

Compression:

Stored size: 1.33 KB

Contents

require 'spec_helper'

describe 'a secure Rails API' do
  describe 'POST request to an API-only action' do
    subject(:api_call) { post '/rails_api/secure_resource' }

    context 'with an authenticated user', :auth_request do
      it 'should be successful' do
        api_call
        expect(response).to be_http_ok
      end
    end

    context 'without an authenticated user' do
      it 'should be unauthorized' do
        api_call
        expect(response).to be_http_unauthorized
      end
    end
  end

  describe 'GET json request to mixed API/website action' do
    subject(:api_call) { get '/rails_api/secure_resource.json' }

    context 'with an authenticated user', :auth_request do
      it 'should be successful' do
        api_call
        expect(response).to be_http_ok
      end
    end

    context 'without an authenticated user' do
      it 'should be unauthorized' do
        api_call
        expect(response).to be_http_unauthorized
      end
    end
  end

  describe 'GET html request to mixed API/website action' do
    subject(:website_call) { get '/rails_api/secure_resource.html' }

    it 'should be a redirect' do
      website_call
      expect(response).to be_redirect
    end

    it 'should redirect to the new session path' do
      website_call
      expect(response).to redirect_to('/g5_auth/users/sign_in')
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
g5_authenticatable-0.9.1.pre.2 spec/requests/rails_api_spec.rb
g5_authenticatable-0.8.1.pre spec/requests/rails_api_spec.rb
g5_authenticatable-0.8.0 spec/requests/rails_api_spec.rb
g5_authenticatable-0.8.0.beta1 spec/requests/rails_api_spec.rb
g5_authenticatable-0.7.5 spec/requests/rails_api_spec.rb
g5_authenticatable-0.7.5.beta spec/requests/rails_api_spec.rb
g5_authenticatable-0.7.4 spec/requests/rails_api_spec.rb
g5_authenticatable-0.7.4.beta.1 spec/requests/rails_api_spec.rb
g5_authenticatable-0.7.3 spec/requests/rails_api_spec.rb
g5_authenticatable-0.7.2 spec/requests/rails_api_spec.rb
g5_authenticatable-0.7.1 spec/requests/rails_api_spec.rb
g5_authenticatable-0.7.0 spec/requests/rails_api_spec.rb
g5_authenticatable-0.6.0 spec/requests/rails_api_spec.rb
g5_authenticatable-0.5.1 spec/requests/rails_api_spec.rb
g5_authenticatable-0.5.0 spec/requests/rails_api_spec.rb
g5_authenticatable-0.4.2 spec/requests/rails_api_spec.rb
g5_authenticatable-0.4.1 spec/requests/rails_api_spec.rb
g5_authenticatable-0.4.0 spec/requests/rails_api_spec.rb
g5_authenticatable-0.3.0 spec/requests/rails_api_spec.rb