<commit_before>require File.expand_path("../../../../test_helper", __FILE__)

# :stopdoc:
module Admin
  module People
    class IndexTest < ActionController::TestCase
      tests Admin::PeopleController

      def setup
        super
        create_administrator_session
        use_ssl
      end
    
      def test_not_logged_in_index
        destroy_person_session
        get(:index)
        assert_redirected_to new_person_session_url(secure_redirect_options)
        assert_nil(@request.session["person"], "No person in session")
      end

      def test_not_logged_in_edit
        destroy_person_session
        person = FactoryGirl.create(:person)
        get(:edit, :id => person.to_param)
        assert_nil(@request.session["person"], "No person in session")
        assert_redirected_to new_person_session_url(secure_redirect_options)
      end

      def test_index
        get(:index)
        assert_response :success
        assert_template("admin/people/index")
        assert_layout("admin/application")
        assert_not_nil(assigns["people"], "Should assign people")
        assert(assigns["people"].empty?, "Should have no people")
        assert_not_nil(assigns["name"], "Should assign name")
      end

      def test_find
        person = FactoryGirl.create(:person)
        get(:index, :name => 'weav')
        assert_response :success
        assert_template("admin/people/index")
        assert_not_nil(assigns["people"], "Should assign people")
        assert_equal([ person ], assigns['people'], 'Search for weav should find Weaver')
        assert_not_nil(assigns["name"], "Should assign name")
        assert_equal('weav', assigns['name'], "'name' assigns")
      end

      def test_find_by_number
        FactoryGirl.create(:discipline)
        FactoryGirl.create(:number_issuer)
        person = FactoryGirl.create(:person, :road_number => "102")
        get(:index, :name => '102')
        assert_response :success
        assert_template("admin/people/index")
        assert_not_nil(assigns["people"], "Should assign people")
        assert_equal([person], assigns['people'], 'Search for 102 should find person')
        assert_not_nil(assigns["name"], "Should assign name")
        assert_equal('102', assigns['name'], "'name' assigns")
      end

      def test_find_nothing
        FactoryGirl.create(:person)
        get(:index, :name => 's7dfnacs89danfx')
        assert_response :success
        assert_template("admin/people/index")
        assert_not_nil(assigns["people"], "Should assign people")
        assert_equal(0, assigns['people'].size, "Should find no people")
      end

      def test_find_empty_name<commit_msg>Fix test error<commit_after>require File.expand_path("../../../../test_helper", __FILE__)

# :stopdoc:
module Admin
  module People
    class IndexTest < ActionController::TestCase
      tests Admin::PeopleController

      def setup
        super
        create_administrator_session
        use_ssl
      end
    
      def test_not_logged_in_index
        destroy_person_session
        get(:index)
        assert_redirected_to new_person_session_url(secure_redirect_options)
        assert_nil(@request.session["person"], "No person in session")
      end

      def test_not_logged_in_edit
        destroy_person_session
        person = FactoryGirl.create(:person)
        get(:edit, :id => person.to_param)
        assert_nil(@request.session["person"], "No person in session")
        assert_redirected_to new_person_session_url(secure_redirect_options)
      end

      def test_index
        get(:index)
        assert_response :success
        assert_template("admin/people/index")
        assert_layout("admin/application")
        assert_not_nil(assigns["people"], "Should assign people")
        assert(assigns["people"].empty?, "Should have no people")
        assert_not_nil(assigns["name"], "Should assign name")
      end

      def test_find
        person = FactoryGirl.create(:person)
        get(:index, :name => 'weav')
        assert_response :success
        assert_template("admin/people/index")
        assert_not_nil(assigns["people"], "Should assign people")
        assert_equal([ person ], assigns['people'], 'Search for weav should find Weaver')
        assert_not_nil(assigns["name"], "Should assign name")
        assert_equal('weav', assigns['name'], "'name' assigns")
      end

      def test_find_by_number
        FactoryGirl.create(:discipline)
        FactoryGirl.create(:number_issuer)
        person = FactoryGirl.create(:person, :road_number => "777")
        get(:index, :name => '777')
        assert_response :success
        assert_template("admin/people/index")
        assert_not_nil(assigns["people"], "Should assign people")
        assert_equal([person], assigns['people'], 'Search for 102 should find person')
        assert_not_nil(assigns["name"], "Should assign name")
        assert_equal('777', assigns['name'], "'name' assigns")
      end

      def test_find_nothing
        FactoryGirl.create(:person)
        get(:index, :name => 's7dfnacs89danfx')
        assert_response :success
        assert_template("admin/people/index")
        assert_not_nil(assigns["people"], "Should assign people")
        assert_equal(0, assigns['people'].size, "Should find no people")
      end

      def test_find_empty_name
{'fraction_non_alphanumeric': 0.11196405167571616, 'fraction_numerical': 0.00599138738064033, 'mean_word_length': 3.043906131718395, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2262094', 'n_tokens_mistral': 1521, 'n_tokens_neox': 1454, 'n_words': 315}