Sha256: 3cdbc1d21d032653a95ca539ded4e1bee6a01be92f5dc0940f38123d30cf149a

Contents?: true

Size: 889 Bytes

Versions: 3

Compression:

Stored size: 889 Bytes

Contents

require 'ostruct'

require 'spec_helper'

describe AuthenticatedController do
  describe "not authenticated" do
    it "redirects to the identity_provider" do
      get :index

      expect(response.location).to match('/auth/gaggleamp')
    end

    it "sets origin to the location an unauthenticated user was trying to access" do
      get :index

      response.location.split('?').last.tap do |query_string|
        expect(query_string.split('=').first).to eq('origin')
        expect(query_string.split('=').last).to eq(CGI.escape '/authenticated')
      end
    end
  end

  describe "after authenticating" do
    let(:user) { OpenStruct.new.tap { |i| i.id = rand(10000) } }
    before do
      sign_in user
      Foyer.user_finder = lambda { |_| user }
    end

    it "allows user to access the action" do
      get :index

      expect(response.status).to eq 200
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
foyer-0.2.0 spec/controllers/authenticated_controller_spec.rb
foyer-0.1.3 spec/controllers/authenticated_controller_spec.rb
foyer-0.1.2 spec/controllers/authenticated_controller_spec.rb