<commit_before>require 'test_helper'

class MoreParanoidTest < ParanoidBaseTest
  test "cannot find a paranoid deleted many:many association" do
    left = ParanoidManyManyParentLeft.create
    right = ParanoidManyManyParentRight.create
    left.paranoid_many_many_parent_rights << right
    
    child = left.paranoid_many_many_children.first

    left.paranoid_many_many_parent_rights.delete(right)

    left.reload
    
    assert_equal [], left.paranoid_many_many_children
    assert_equal [], left.paranoid_many_many_parent_rights, "Associated objects not deleted"
    assert_equal right, ParanoidManyManyParentRight.find(right.id)
  end
  
  test "cannot find a paranoid destroyed many:many association" do
    left = ParanoidManyManyParentLeft.create
    right = ParanoidManyManyParentRight.create
    left.paranoid_many_many_parent_rights << right
    
    child = left.paranoid_many_many_children.first

    left.paranoid_many_many_parent_rights.destroy(right)
    
    left.reload
    
    assert_equal [], left.paranoid_many_many_children, "Child records still exist"
    assert_equal [], left.paranoid_many_many_parent_rights, "Associated objects not deleted"
    
    # Destroying the associated really destroys it; it's not just removed from the collection
    assert_raises ActiveRecord::RecordNotFound do
      ParanoidManyManyParentRight.find(right.id)
    end
  end<commit_msg>associated object destroy no longer destroys the actual object<commit_after>require 'test_helper'

class MoreParanoidTest < ParanoidBaseTest
  test "cannot find a paranoid deleted many:many association" do
    left = ParanoidManyManyParentLeft.create
    right = ParanoidManyManyParentRight.create
    left.paranoid_many_many_parent_rights << right
    
    child = left.paranoid_many_many_children.first

    left.paranoid_many_many_parent_rights.delete(right)

    left.reload
    
    assert_equal [], left.paranoid_many_many_children
    assert_equal [], left.paranoid_many_many_parent_rights, "Associated objects not deleted"
    assert_equal right, ParanoidManyManyParentRight.find(right.id)
  end
  
  test "cannot find a paranoid destroyed many:many association" do
    left = ParanoidManyManyParentLeft.create
    right = ParanoidManyManyParentRight.create
    left.paranoid_many_many_parent_rights << right
    
    child = left.paranoid_many_many_children.first

    left.paranoid_many_many_parent_rights.destroy(right)
    
    left.reload
    
    assert_equal [], left.paranoid_many_many_children, "Child records still exist"
    assert_equal [], left.paranoid_many_many_parent_rights, "Associated objects not deleted"
    assert_equal right, ParanoidManyManyParentRight.find(right.id)
  end
{'fraction_non_alphanumeric': 0.05851851851851852, 'fraction_numerical': 0.0, 'mean_word_length': 4.6037344398340245, 'pattern_counts': {'":': 0, '<': 13, '<?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': '487771', 'n_tokens_mistral': 841, 'n_tokens_neox': 806, 'n_words': 168}