Sha256: 1491b98932f93470af7a99a662e1e14a17efe69f9ea337635583a22e96393d4a

Contents?: true

Size: 1002 Bytes

Versions: 1

Compression:

Stored size: 1002 Bytes

Contents

require "spec_helper"

describe PrivateController, type: :controller do
  describe "GET index" do
    context "user is not logged in" do
      it "redirects" do
        get :index
        expect(response).to redirect_to("/auth/sign_in")
      end
    end

    context "user is logged in but not in valid group" do
      it "returns a 302" do
        LsOmniauth::AuthSessions.new(session).auth.set('user@domain.com')
        get :index
        assert_response 401
      end

      context "when running in dev mode" do
        before(:each) {
          expect(LS_OMNIAUTH.config).to receive(:[]).with(:dev_mode).and_return(true)
        }
        it "returns a 200" do
          get :index

          assert_response 200
        end
      end
    end

    context "user is logged in and is in valid group" do
      it "returns a 200" do
        LsOmniauth::AuthSessions.new(session).auth.set('dan.rabinowitz@hungrymachine.com')
        get :index
        assert_response 200
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ls-omniauth-3.0.3 spec/dummy/spec/controllers/private_controller_spec.rb