<commit_before>require 'test_helper'

class ClientActivityFilterTest < ActionDispatch::IntegrationTest
  def setup
    @superadmin = create :user
    @client_accepted = create :client, acceptance: 'accepted'
    create :assignment_active, client: @client_accepted
    @client_rejected = create :client, acceptance: 'rejected'
    create :assignment_active, client: @client_rejected
    @client_resigned = create :client, acceptance: 'resigned'
    create :assignment_active, client: @client_resigned
    login_as @superadmin
  end

  test 'client_tandem_active_filter_returns_accepted_active_client' do
    get clients_path(q: { active_eq: 'true' })
    assert response.body.include? @client_accepted.contact.full_name
    refute response.body.include? @client_rejected.contact.full_name
    refute response.body.include? @client_resigned.contact.full_name
  end

  test 'client_tandem_inactive_filter_returns_accepted_inactive_client' do
    get clients_path(q: { active_eq: 'false' })
    refute response.body.include? @client_accepted.contact.full_name
    refute response.body.include? @client_rejected.contact.full_name
    refute response.body.include? @client_resigned.contact.full_name
  end

  test 'client_acceptance_tandem_filters_work_together' do
    get clients_path(q: { acceptance_eq: '0', active_eq: 'true' })
    assert response.body.include? @client_accepted.contact.full_name
    refute response.body.include? @client_rejected.contact.full_name
    refute response.body.include? @client_resigned.contact.full_name

    get clients_path(q: { acceptance_eq: '0', active_eq: 'false' })
    refute response.body.include? @client_accepted.contact.full_name
    refute response.body.include? @client_rejected.contact.full_name
    refute response.body.include? @client_resigned.contact.full_name

    get clients_path(q: { acceptance_eq: '1', active_eq: 'true' })
    refute response.body.include? @client_accepted.contact.full_name
    refute response.body.include? @client_rejected.contact.full_name
    refute response.body.include? @client_resigned.contact.full_name

    get clients_path(q: { acceptance_eq: '1', active_eq: 'false' })
    refute response.body.include? @client_accepted.contact.full_name
    refute response.body.include? @client_rejected.contact.full_name
    refute response.body.include? @client_resigned.contact.full_name

    get clients_path(q: { acceptance_eq: '2', active_eq: 'true' })
    refute response.body.include? @client_accepted.contact.full_name
    refute response.body.include? @client_rejected.contact.full_name
    refute response.body.include? @client_resigned.contact.full_name

    get clients_path(q: { acceptance_eq: '2', active_eq: 'false' })
    refute response.body.include? @client_accepted.contact.full_name
    refute response.body.include? @client_rejected.contact.full_name
    refute response.body.include? @client_resigned.contact.full_name
  end
end<commit_msg>fix client activity filter test<commit_after>require 'test_helper'

class ClientActivityFilterTest < ActionDispatch::IntegrationTest
  def setup
    @superadmin = create :user
    @client_accepted = create :client, acceptance: 'accepted'
    create :assignment_active, client: @client_accepted
    @client_rejected = create :client, acceptance: 'rejected'
    create :assignment_active, client: @client_rejected
    @client_resigned = create :client, acceptance: 'accepted'
    create :assignment_active, client: @client_resigned, period_end: 2.days.ago
    @client_resigned.resigned!
    login_as @superadmin
  end

  test 'client_tandem_active_filter_returns_accepted_active_client' do
    get clients_path(q: { active: 'true' })
    assert response.body.include? @client_accepted.contact.full_name
    refute response.body.include? @client_rejected.contact.full_name
    refute response.body.include? @client_resigned.contact.full_name
  end

  test 'client_tandem_inactive_filter_returns_accepted_inactive_client' do
    get clients_path(q: { inactive: 'true' })
    refute response.body.include? @client_accepted.contact.full_name
    refute response.body.include? @client_rejected.contact.full_name
    refute response.body.include? @client_resigned.contact.full_name
  end

  test 'client_acceptance_tandem_filters_work_together' do
    get clients_path(q: { acceptance_eq: '0', active: 'true' })
    assert response.body.include? @client_accepted.contact.full_name
    refute response.body.include? @client_rejected.contact.full_name
    refute response.body.include? @client_resigned.contact.full_name

    get clients_path(q: { acceptance_eq: '0', inactive: 'true' })
    refute response.body.include? @client_accepted.contact.full_name
    refute response.body.include? @client_rejected.contact.full_name
    refute response.body.include? @client_resigned.contact.full_name

    get clients_path(q: { acceptance_eq: '1', active: 'true' })
    refute response.body.include? @client_accepted.contact.full_name
    refute response.body.include? @client_rejected.contact.full_name
    refute response.body.include? @client_resigned.contact.full_name

    get clients_path(q: { acceptance_eq: '1', inactive: 'true' })
    refute response.body.include? @client_accepted.contact.full_name
    refute response.body.include? @client_rejected.contact.full_name
    refute response.body.include? @client_resigned.contact.full_name

    get clients_path(q: { acceptance_eq: '2' })
    refute response.body.include? @client_accepted.contact.full_name
    refute response.body.include? @client_rejected.contact.full_name
    assert response.body.include? @client_resigned.contact.full_name
  end
end
{'fraction_non_alphanumeric': 0.09575413039616273, 'fraction_numerical': 0.0021318173743116006, 'mean_word_length': 5.207276736493936, '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': '5028523', 'n_tokens_mistral': 1785, 'n_tokens_neox': 1757, 'n_words': 327}