1 require File.dirname(__FILE__) + '/../test_helper'
3 class NodeTagTest < Test::Unit::TestCase
7 assert_equal 7, NodeTag.count
8 node_tag_count(:visible_node, 1)
9 node_tag_count(:invisible_node, 1)
10 node_tag_count(:used_node_1, 1)
11 node_tag_count(:used_node_2, 1)
12 node_tag_count(:node_with_versions, 2)
15 def node_tag_count (node, count)
16 nod = current_nodes(node)
17 assert_equal count, nod.node_tags.count
20 def test_length_key_valid
24 tag.id = current_node_tags(:t1).id
31 def test_length_value_valid
35 tag.id = current_node_tags(:t1).id
42 def test_length_key_invalid
45 tag.id = current_node_tags(:t1).id
48 assert !tag.valid?, "Key should be too long"
49 assert tag.errors.invalid?(:k)
53 def test_length_value_invalid
56 tag.id = current_node_tags(:t1).id
59 assert !tag.valid?, "Value should be too long"
60 assert tag.errors.invalid?(:v)
64 def test_empty_node_tag_invalid
66 assert !tag.valid?, "Empty tag should be invalid"
67 assert tag.errors.invalid?(:id)
72 tag.id = current_node_tags(:t1).id
73 tag.k = current_node_tags(:t1).k
74 tag.v = current_node_tags(:t1).v
75 assert tag.new_record?
77 assert_raise(ActiveRecord::RecordInvalid) {tag.save!}
78 assert tag.new_record?