<commit_before>require 'test_helper'

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

  test "should destroy event and not destroy associated sheets" do
    @subject_event = subject_events(:one)
    assert_difference('SubjectEvent.count', -1) do
      assert_difference('Sheet.current.count', 0) do<commit_msg>Added test for subjects controller subject json search<commit_after>require 'test_helper'

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

  test "should get search for regular user" do
    get :search, project_id: @project, q: 'Code01'
    subjects_json = JSON.parse(response.body)
    assert_equal 'Code01', subjects_json.first['value']
    assert_equal 'Code01', subjects_json.first['subject_code']
    assert_equal 'success', subjects_json.first['status_class']
    assert_equal 'v', subjects_json.first['status']
    assert_response :success
  end

  test "should destroy event and not destroy associated sheets" do
    @subject_event = subject_events(:one)
    assert_difference('SubjectEvent.count', -1) do
      assert_difference('Sheet.current.count', 0) do
{'fraction_non_alphanumeric': 0.10445468509984639, 'fraction_numerical': 0.007680491551459293, 'mean_word_length': 4.84304932735426, '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': '6261882', 'n_tokens_mistral': 377, 'n_tokens_neox': 363, 'n_words': 99}