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.6.2 spec/controllers/users/sessions_controller_spec.rb
ddr-models-2.6.1 spec/controllers/users/sessions_controller_spec.rb
ddr-models-2.6.0 spec/controllers/users/sessions_controller_spec.rb
ddr-models-2.6.0.rc4 spec/controllers/users/sessions_controller_spec.rb
ddr-models-2.6.0.rc3 spec/controllers/users/sessions_controller_spec.rb
ddr-models-2.6.0.rc2 spec/controllers/users/sessions_controller_spec.rb
ddr-models-2.6.0.rc1 spec/controllers/users/sessions_controller_spec.rb
ddr-models-2.5.3 spec/controllers/users/sessions_controller_spec.rb
ddr-models-2.5.2 spec/controllers/users/sessions_controller_spec.rb
ddr-models-2.5.1 spec/controllers/users/sessions_controller_spec.rb
ddr-models-2.5.0 spec/controllers/users/sessions_controller_spec.rb
ddr-models-2.5.0.rc1 spec/controllers/users/sessions_controller_spec.rb
ddr-models-2.4.16 spec/controllers/users/sessions_controller_spec.rb
ddr-models-2.4.15 spec/controllers/users/sessions_controller_spec.rb
ddr-models-2.4.14 spec/controllers/users/sessions_controller_spec.rb
ddr-models-2.4.13 spec/controllers/users/sessions_controller_spec.rb
ddr-models-2.4.12 spec/controllers/users/sessions_controller_spec.rb
ddr-models-2.4.11 spec/controllers/users/sessions_controller_spec.rb
ddr-models-3.0.8 spec/controllers/users/sessions_controller_spec.rb
ddr-models-3.0.7 spec/controllers/users/sessions_controller_spec.rb