Sha256: aae2160bed8106f85faf2f33410eefcca7509f6eed5bb072f6a08be377d586c6

Contents?: true

Size: 714 Bytes

Versions: 4

Compression:

Stored size: 714 Bytes

Contents

require 'ostruct'
require 'spec_helper'

describe 'authentication via routes helper', type: :request do
  it 'does not allow an unauthenticated user to access to route' do
    expect { get '/authenticated_by_route_constraint' }.to raise_error(ActionController::RoutingError)
  end

  it 'allows authenticated users to access the route' do
    post '/sign_in'

    get '/authenticated_by_route_constraint'

    expect(response).to be_success
  end

  it 'allows only certain users to access the route' do
    Foyer.user_finder = ->(_user_id) { nil }

    post '/sign_in'

    expect { get '/authenticated_by_route_constraint_which_blocks_all_users' }
      .to raise_error(ActionController::RoutingError)
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
foyer-0.4.0 spec/integration/authenticate_via_route_constraint_spec.rb
foyer-0.3.1 spec/integration/authenticate_via_route_constraint_spec.rb
foyer-0.2.2 spec/integration/authenticate_via_route_constraint_spec.rb
foyer-0.2.1 spec/integration/authenticate_via_route_constraint_spec.rb