Sha256: c2dd2a6b6057daf0f2eba74fc9992ffd2dc43e842f11a3bb6ea6ae9e938bd8b7

Contents?: true

Size: 1.95 KB

Versions: 1

Compression:

Stored size: 1.95 KB

Contents

require 'test_helper'
class ApplicationControllerTest < ActiveSupport::TestCase

  def setup
    activate_authlogic
    controller.session[:session_id] = "FakeSessionID"
    Institutions.send(:instance_variable_set, :@loadpaths, nil)
    Institutions.send(:instance_variable_set, :@institutions, nil)
    controller.instance_variable_set(:@current_primary_institution, nil)
  end

  test "current_user_session_nil" do
    assert_nil(controller.current_user_session)
  end

  test "current_user_session" do
    assert_nil(controller.current_user_session)
    controller.cookies[:PDS_HANDLE] = { :value => VALID_PDS_HANDLE_FOR_NYU }
    user_session = controller.current_user_session
    assert_not_nil(user_session)
  end

  test "current_user_nil" do
    assert_nil(controller.current_user)
  end

  test "current_user" do
    assert_nil(controller.current_user)
    controller.cookies[:PDS_HANDLE] = { :value => VALID_PDS_HANDLE_FOR_NYU }
    user = controller.current_user
    assert_not_nil(user)
    assert_equal("N12162279", user.username)
  end

  test "current_primary_institution_nil" do
    assert_nil(controller.current_primary_institution)
  end

  test "current_primary_institution_default" do
    assert_nil(controller.current_primary_institution)
    controller.request[:session_id] = "FakeSessionID"
    Institutions.loadpaths<< "#{File.dirname(__FILE__)}/../support/config"
    assert_equal(Institutions.institutions[:NYUAD], controller.current_primary_institution)
  end

  test "current_primary_institution_user" do
    assert_nil(controller.current_primary_institution)
    Institutions.loadpaths<< "#{File.dirname(__FILE__)}/../support/config"
    controller.cookies[:PDS_HANDLE] = { :value => VALID_PDS_HANDLE_FOR_NYU }
    assert_equal("N12162279", controller.current_user.username)
    assert_equal(Institutions.institutions[:NYU], controller.current_user.primary_institution)
    assert_equal(Institutions.institutions[:NYU], controller.current_primary_institution)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
authpds-0.2.0 test/unit/authpds_controller_test.rb