Sha256: c6aa58b9e57658aaf8630eba3f72b4add139095f3d5f656d69061151c05fc226

Contents?: true

Size: 1.34 KB

Versions: 126

Compression:

Stored size: 1.34 KB

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" }
    it "should store the location of the previous page" do
      expect(subject).to receive(:store_location_for).with(:user, "/foo/bar")
      get :new
    end
    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" do
        get :new
        expect(response).to redirect_to(user_omniauth_authorize_path(:shibboleth))
      end
      it "should discard the flash alert" do
        expect_any_instance_of(ActionDispatch::Flash::FlashHash).to receive(:discard).with(:alert)
        get :new
      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
        get :new
        expect(response).to render_template(:new)
      end
      it "should NOT discard the flash alert" do
        expect_any_instance_of(ActionDispatch::Flash::FlashHash).not_to receive(:discard).with(:alert)
        get :new
      end
    end
  end

end

Version data entries

126 entries across 126 versions & 1 rubygems

Version Path
ddr-models-2.11.0 spec/controllers/users/sessions_controller_spec.rb
ddr-models-2.10.2 spec/controllers/users/sessions_controller_spec.rb
ddr-models-2.10.1 spec/controllers/users/sessions_controller_spec.rb
ddr-models-2.10.0 spec/controllers/users/sessions_controller_spec.rb
ddr-models-2.10.0.rc2 spec/controllers/users/sessions_controller_spec.rb
ddr-models-2.10.0.rc1 spec/controllers/users/sessions_controller_spec.rb
ddr-models-2.9.2 spec/controllers/users/sessions_controller_spec.rb
ddr-models-2.9.1 spec/controllers/users/sessions_controller_spec.rb
ddr-models-2.9.0 spec/controllers/users/sessions_controller_spec.rb
ddr-models-2.9.0.rc1 spec/controllers/users/sessions_controller_spec.rb
ddr-models-2.8.0 spec/controllers/users/sessions_controller_spec.rb
ddr-models-2.8.0.rc1 spec/controllers/users/sessions_controller_spec.rb
ddr-models-2.7.6 spec/controllers/users/sessions_controller_spec.rb
ddr-models-2.7.5 spec/controllers/users/sessions_controller_spec.rb
ddr-models-2.7.4 spec/controllers/users/sessions_controller_spec.rb
ddr-models-2.7.3 spec/controllers/users/sessions_controller_spec.rb
ddr-models-2.7.2 spec/controllers/users/sessions_controller_spec.rb
ddr-models-2.7.1 spec/controllers/users/sessions_controller_spec.rb
ddr-models-2.7.0 spec/controllers/users/sessions_controller_spec.rb
ddr-models-2.7.0.rc1 spec/controllers/users/sessions_controller_spec.rb