Sha256: 0963e3f0c286b5901bd1a094083d1db64bad7a05642a428e00ab89d00cf90f40

Contents?: true

Size: 1007 Bytes

Versions: 1

Compression:

Stored size: 1007 Bytes

Contents

RSpec.describe Users::SessionsController, type: :controller do

  before { request.env["devise.mapping"] = Devise.mappings[:user] }

  describe "#new" do
    before { request.env["HTTP_REFERER"] = "/foo/bar" }
    describe "when shibboleth user authentication is required" do
      before { allow(Ddr::Auth).to receive(:require_shib_user_authn) { true } }
      it "should redirect to the shib authn path, setting the origin to the previous page" do
        get :new
        expect(response).to redirect_to(user_omniauth_authorize_path(:shibboleth, origin: "/foo/bar"))
      end
    end

    describe "when shibboleth user authentication is NOT required" do
      before { allow(Ddr::Auth).to receive(:require_shib_user_authn) { false } }
      it "should store the location of the previous page and render the 'new' template" do
        expect(subject).to receive(:store_location_for).with(:user, "/foo/bar")
        get :new
        expect(response).to render_template(:new)
      end
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ddr-models-1.11.0 spec/controllers/users/sessions_controller_spec.rb