<commit_before>require 'test_helper'

class ProjectsControllerTest < ActionController::TestCase
  setup do
    login(users(:valid))
    @project = projects(:one)
  end

  test "should get subject report" do
    get :subject_report, id: @project
    assert_not_nil assigns(:project)
    assert_not_nil assigns(:subjects)
    assert_not_nil assigns(:designs)
    assert_response :success
  end

  test "should not get subject report for invalid project" do
    get :subject_report, id: -1
    assert_nil assigns(:project)
    assert_redirected_to projects_path
  end

  test "should get splash" do
    get :splash
    assert_not_nil assigns(:projects)
    assert_response :success
  end

  test "should get paginated splash" do
    get :splash, format: 'js'
    assert_not_nil assigns(:projects)<commit_msg>Added tests for quick search<commit_after>require 'test_helper'

class ProjectsControllerTest < ActionController::TestCase
  setup do
    login(users(:valid))
    @project = projects(:one)
  end

  test "should get search" do
    get :search, search: ''

    assert_not_nil assigns(:subjects)
    assert_not_nil assigns(:projects)
    assert_not_nil assigns(:designs)
    assert_not_nil assigns(:variables)
    assert_not_nil assigns(:objects)

    assert_response :success
  end

  test "should get search and redirect" do
    get :search, search: 'Project With One Design'

    assert_not_nil assigns(:subjects)
    assert_not_nil assigns(:projects)
    assert_not_nil assigns(:designs)
    assert_not_nil assigns(:variables)
    assert_not_nil assigns(:objects)

    assert_equal 1, assigns(:objects).size

    assert_redirected_to assigns(:objects).first
  end

  test "should get search typeahead" do
    get :search, search: 'abc', format: 'json'

    assert_not_nil assigns(:subjects)
    assert_not_nil assigns(:projects)
    assert_not_nil assigns(:designs)
    assert_not_nil assigns(:variables)
    assert_not_nil assigns(:objects)

    assert_response :success
  end

  test "should get subject report" do
    get :subject_report, id: @project
    assert_not_nil assigns(:project)
    assert_not_nil assigns(:subjects)
    assert_not_nil assigns(:designs)
    assert_response :success
  end

  test "should not get subject report for invalid project" do
    get :subject_report, id: -1
    assert_nil assigns(:project)
    assert_redirected_to projects_path
  end

  test "should get splash" do
    get :splash
    assert_not_nil assigns(:projects)
    assert_response :success
  end

  test "should get paginated splash" do
    get :splash, format: 'js'
    assert_not_nil assigns(:projects)
{'fraction_non_alphanumeric': 0.0770410118819471, 'fraction_numerical': 0.0011498658489842851, 'mean_word_length': 4.117647058823529, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '6429091', 'n_tokens_mistral': 819, 'n_tokens_neox': 762, 'n_words': 225}