1 require File.dirname(__FILE__) + '/../test_helper'
3 class NodeTagTest < ActiveSupport::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.node_id = current_node_tags(:t1).node_id
31 def test_length_value_valid
35 tag.node_id = current_node_tags(:t1).node_id
42 def test_length_key_invalid
45 tag.node_id = current_node_tags(:t1).node_id
48 assert !tag.valid?, "Key should be too long"
49 assert tag.errors[:k].any?
53 def test_length_value_invalid
56 tag.node_id = current_node_tags(:t1).node_id
59 assert !tag.valid?, "Value should be too long"
60 assert tag.errors[:v].any?
64 def test_empty_node_tag_invalid
66 assert !tag.valid?, "Empty tag should be invalid"
67 assert tag.errors[:node].any?
72 tag.node_id = current_node_tags(:t1).node_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?