Sha256: e664b2bd8f8f702e12f94c94fb0769f46d3c1527b70cf5a9c8577432fbe6d341

Contents?: true

Size: 1.38 KB

Versions: 36

Compression:

Stored size: 1.38 KB

Contents

RSpec.describe ApplicationController, type: :controller do

  describe "authentication" do
    controller do
      before_action :authenticate_user!
      def index; end
    end

    describe "authentication failure handling" do
      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 :index
          expect(response).to redirect_to(user_omniauth_authorize_path(:shibboleth))
        end
      end

      describe "when shibboleth user authentication is not required" do
        before { allow(Ddr::Auth).to receive(:require_shib_user_authn) { false } }
        it "should redirect to the new user session path" do
          get :index
          expect(response).to redirect_to(new_user_session_path)
        end
      end
    end
  end

  describe "including `Ddr::Auth::RoleBasedAccessControlsEnforcement`" do
    controller do
      include Ddr::Auth::RoleBasedAccessControlsEnforcement
    end

    let(:user) { FactoryGirl.create(:user) }

    its(:current_ability) { is_expected.to be_a(Ddr::Auth::AbstractAbility) }

    it "delegates `authorized_to_act_as_superuser?` to current_ability" do
      expect(subject.current_ability).to receive(:authorized_to_act_as_superuser?)
      subject.authorized_to_act_as_superuser?
    end
  end

end

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
ddr-models-3.0.8 spec/controllers/application_controller_spec.rb
ddr-models-3.0.7 spec/controllers/application_controller_spec.rb
ddr-models-3.0.6 spec/controllers/application_controller_spec.rb
ddr-models-3.0.5 spec/controllers/application_controller_spec.rb
ddr-models-3.0.4 spec/controllers/application_controller_spec.rb
ddr-models-3.0.3 spec/controllers/application_controller_spec.rb
ddr-models-3.0.2 spec/controllers/application_controller_spec.rb
ddr-models-3.0.1 spec/controllers/application_controller_spec.rb
ddr-models-3.0.0 spec/controllers/application_controller_spec.rb
ddr-models-3.0.0.rc6 spec/controllers/application_controller_spec.rb
ddr-models-3.0.0.rc5 spec/controllers/application_controller_spec.rb
ddr-models-3.0.0.rc4 spec/controllers/application_controller_spec.rb
ddr-models-3.0.0.rc3 spec/controllers/application_controller_spec.rb
ddr-models-3.0.0.rc2 spec/controllers/application_controller_spec.rb
ddr-models-3.0.0.rc1 spec/controllers/application_controller_spec.rb
ddr-models-3.0.0.beta.22 spec/controllers/application_controller_spec.rb
ddr-models-3.0.0.beta.21 spec/controllers/application_controller_spec.rb
ddr-models-3.0.0.beta.20 spec/controllers/application_controller_spec.rb
ddr-models-3.0.0.beta.18 spec/controllers/application_controller_spec.rb
ddr-models-3.0.0.beta.17 spec/controllers/application_controller_spec.rb