<commit_before>require 'test_helper'
class VersionTest < Zena::Unit::TestCase
  
  def version(sym)
    secure!(Node) { nodes(sym) }.version
  end
  
  def test_author
    login(:tiger)
    v = versions(:opening_red_fr)
    assert_equal nodes_id(:tiger), v.author[:id]
  end
  
  def test_cannot_set_node_id
    login(:tiger)
    node = Node.new(:v_node_id => 1234)
    assert_nil node.version.node_id
  end
  
  def test_cannot_set_node_id_with_attributes
    login(:tiger)
    node = secure!(Node) { nodes(:status) }
    original_node_id = node.version.node_id
    node.update_attributes(:v_node_id => nodes_id(:lake) )
  end
  
  def test_cannot_set_site_id_with_new_record
    login(:tiger)
    node = Node.new(:site_id => 1234)
    assert_nil node.site_id
  end
  
  def test_cannot_set_site_id_with_old_record
    login(:tiger)
    node = secure!(Node) { nodes(:status) }
    original_site_id = node.site_id
    node.update_attributes(:v_site_id => 1234)
    assert_equal original_site_id, node.site_id
  end
  
  def test_cannot_set_site_id_by_attribute
    login(:tiger)
    node = secure!(Node) { nodes(:status) }
    original_site_id = node.site_id
    node.update_attributes(:v_site_id=>sites_id(:ocean))
    assert_equal original_site_id, node.site_id
  end
  
  def test_cannot_set_node_id_on_create
    login(:tiger)
    node = Node.create(:v_node_id=>nodes_id(:lake))
    assert_nil node.version.node_id
  end
  
  def test_cannot_set_content_id
    login(:tiger)
    node = Node.new(:v_content_id => nodes_id(:lake))
    assert_nil node.version.conent_id
  end
  
  def test_cannot_set_content_id_by_attribute
    login(:tiger)
    node = secure!(Node) { nodes(:status) }
    node.update_attributes(:v_content_id=>nodes_id(:lake))
    assert_nil node.version.content_id
  end
  
  def test_cannot_set_content_id_on_create
    login(:tiger)
    node = Node.create(:v_content_id=>nodes_id(:lake))
    assert_nil node.version.content_id
  end<commit_msg>Typo in version_test (conent_id instead of content_id).<commit_after>require 'test_helper'
class VersionTest < Zena::Unit::TestCase
  
  def version(sym)
    secure!(Node) { nodes(sym) }.version
  end
  
  def test_author
    login(:tiger)
    v = versions(:opening_red_fr)
    assert_equal nodes_id(:tiger), v.author[:id]
  end
  
  def test_cannot_set_node_id
    login(:tiger)
    node = Node.new(:v_node_id => 1234)
    assert_nil node.version.node_id
  end
  
  def test_cannot_set_node_id_with_attributes
    login(:tiger)
    node = secure!(Node) { nodes(:status) }
    original_node_id = node.version.node_id
    node.update_attributes(:v_node_id => nodes_id(:lake) )
  end
  
  def test_cannot_set_site_id_with_new_record
    login(:tiger)
    node = Node.new(:site_id => 1234)
    assert_nil node.site_id
  end
  
  def test_cannot_set_site_id_with_old_record
    login(:tiger)
    node = secure!(Node) { nodes(:status) }
    original_site_id = node.site_id
    node.update_attributes(:v_site_id => 1234)
    assert_equal original_site_id, node.site_id
  end
  
  def test_cannot_set_site_id_by_attribute
    login(:tiger)
    node = secure!(Node) { nodes(:status) }
    original_site_id = node.site_id
    node.update_attributes(:v_site_id=>sites_id(:ocean))
    assert_equal original_site_id, node.site_id
  end
  
  def test_cannot_set_node_id_on_create
    login(:tiger)
    node = Node.create(:v_node_id=>nodes_id(:lake))
    assert_nil node.version.node_id
  end
  
  def test_cannot_set_content_id
    login(:tiger)
    node = Node.new(:v_content_id => nodes_id(:lake))
    assert_nil node.version.content_id
  end
  
  def test_cannot_set_content_id_by_attribute
    login(:tiger)
    node = secure!(Node) { nodes(:status) }
    node.update_attributes(:v_content_id=>nodes_id(:lake))
    assert_nil node.version.content_id
  end
  
  def test_cannot_set_content_id_on_create
    login(:tiger)
    node = Node.create(:v_content_id=>nodes_id(:lake))
    assert_nil node.version.content_id
  end
{'fraction_non_alphanumeric': 0.09982398793060096, 'fraction_numerical': 0.0060346995222529546, 'mean_word_length': 4.0227272727272725, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 21, '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': '5970782', 'n_tokens_mistral': 1502, 'n_tokens_neox': 1451, 'n_words': 227}