Sha256: 596974f1683d83d2071a227d2506ba5ec094cf320a1b70d03bd70b6e43c02688

Contents?: true

Size: 715 Bytes

Versions: 5

Compression:

Stored size: 715 Bytes

Contents

require 'ostruct'
require 'spec_helper'

describe "authentication via routes helper" 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 = lambda { |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

5 entries across 5 versions & 1 rubygems

Version Path
foyer-0.2.0 spec/integration/authenticate_via_route_constraint_spec.rb
foyer-0.1.3 spec/integration/authenticate_via_route_constraint_spec.rb
foyer-0.1.2 spec/integration/authenticate_via_route_constraint_spec.rb
foyer-0.1.1 spec/integration/authenticate_via_route_constraint_spec.rb
foyer-0.1.0 spec/integration/authenticate_via_route_constraint_spec.rb