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-3.0.0.beta.17 spec/controllers/users/sessions_controller_spec.rb
ddr-models-3.0.0.beta.16 spec/controllers/users/sessions_controller_spec.rb
ddr-models-3.0.0.beta.15 spec/controllers/users/sessions_controller_spec.rb
ddr-models-3.0.0.beta.14 spec/controllers/users/sessions_controller_spec.rb
ddr-models-3.0.0.beta.13 spec/controllers/users/sessions_controller_spec.rb
ddr-models-3.0.0.beta.12 spec/controllers/users/sessions_controller_spec.rb
ddr-models-3.0.0.beta.11 spec/controllers/users/sessions_controller_spec.rb
ddr-models-2.4.7 spec/controllers/users/sessions_controller_spec.rb
ddr-models-2.4.6 spec/controllers/users/sessions_controller_spec.rb
ddr-models-2.4.5 spec/controllers/users/sessions_controller_spec.rb
ddr-models-3.0.0.beta.10 spec/controllers/users/sessions_controller_spec.rb
ddr-models-3.0.0.beta.9 spec/controllers/users/sessions_controller_spec.rb
ddr-models-3.0.0.beta.8 spec/controllers/users/sessions_controller_spec.rb
ddr-models-3.0.0.beta.7 spec/controllers/users/sessions_controller_spec.rb
ddr-models-2.4.4 spec/controllers/users/sessions_controller_spec.rb
ddr-models-3.0.0.beta.6 spec/controllers/users/sessions_controller_spec.rb
ddr-models-2.4.3 spec/controllers/users/sessions_controller_spec.rb
ddr-models-2.4.2 spec/controllers/users/sessions_controller_spec.rb
ddr-models-3.0.0.beta.4 spec/controllers/users/sessions_controller_spec.rb
ddr-models-2.4.1 spec/controllers/users/sessions_controller_spec.rb