<commit_before># frozen_string_literal: true

require 'test_helper'

class ConversationTest < ActiveSupport::TestCase
  def setup
    super

    @user, @recipient = create_list(:user, 2)

    @conversation = create(:conversation, originator: @user,
                                          recipient: @recipient)
  end

  def test_unread_by_scope_returns_unread_conversations_only
    assert_equal 0, Conversation.unread_by(@user).size
    assert_equal 1, Conversation.unread_by(@recipient).size
  end

  def test_mark_as_read_does_what_its_name_indicates
    @conversation.mark_as_read(@recipient)

    assert_equal 0, Conversation.unread_by(@user).size
    assert_equal 0, Conversation.unread_by(@recipient).size
  end

  def test_unread_by_scope_excludes_deleted_conversations
    @conversation.move_to_trash(@recipient)

    assert_equal 0, Conversation.unread_by(@user).size
    assert_equal 0, Conversation.unread_by(@recipient).size
  end

  def test_unread_by_scope_excludes_conversations_with_blockers
    create(:blocking, blocker: @user, blocked: @recipient)

    assert_equal 0, Conversation.unread_by(@user).size
  end
<commit_msg>Put all `unread_by` tests together<commit_after># frozen_string_literal: true

require 'test_helper'

class ConversationTest < ActiveSupport::TestCase
  def setup
    super

    @user, @recipient = create_list(:user, 2)

    @conversation = create(:conversation, originator: @user,
                                          recipient: @recipient)
  end

  def test_unread_by_scope_returns_unread_conversations_only
    assert_equal 0, Conversation.unread_by(@user).size
    assert_equal 1, Conversation.unread_by(@recipient).size
  end

  def test_unread_by_scope_excludes_deleted_conversations
    @conversation.move_to_trash(@recipient)

    assert_equal 0, Conversation.unread_by(@user).size
    assert_equal 0, Conversation.unread_by(@recipient).size
  end

  def test_unread_by_scope_excludes_conversations_with_blockers
    create(:blocking, blocker: @user, blocked: @recipient)

    assert_equal 0, Conversation.unread_by(@user).size
  end

  def test_mark_as_read_does_what_its_name_indicates
    @conversation.mark_as_read(@recipient)

    assert_equal 0, Conversation.unread_by(@user).size
    assert_equal 0, Conversation.unread_by(@recipient).size
  end

{'fraction_non_alphanumeric': 0.07875378623972307, 'fraction_numerical': 0.006923409779316313, 'mean_word_length': 4.5443645083932855, '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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6119475', 'n_tokens_mistral': 792, 'n_tokens_neox': 735, 'n_words': 128}