1 require File.dirname(__FILE__) + '/../test_helper'
3 class NodeTagTest < Test::Unit::TestCase
4 fixtures :current_node_tags, :current_nodes
5 set_fixture_class :current_nodes => Node
6 set_fixture_class :current_node_tags => NodeTag
9 assert_equal 6, NodeTag.count
10 node_tag_count(:visible_node, 1)
11 node_tag_count(:invisible_node, 1)
12 node_tag_count(:used_node_1, 1)
13 node_tag_count(:used_node_2, 1)
14 node_tag_count(:node_with_versions, 2)
17 def node_tag_count (node, count)
18 nod = current_nodes(node)
19 assert_equal count, nod.node_tags.count
22 def test_length_key_valid
26 tag.id = current_node_tags(:t1).id
33 def test_length_value_valid
37 tag.id = current_node_tags(:t1).id
44 def test_length_key_invalid
47 tag.id = current_node_tags(:t1).id
50 assert !tag.valid?, "Key should be too long"
51 assert tag.errors.invalid?(:k)
55 def test_length_value_invalid
58 tag.id = current_node_tags(:t1).id
61 assert !tag.valid?, "Value should be too long"
62 assert tag.errors.invalid?(:v)
66 def test_empty_node_tag_invalid
68 assert !tag.valid?, "Empty tag should be invalid"
69 assert tag.errors.invalid?(:id)
74 tag.id = current_node_tags(:t1).id
75 tag.k = current_node_tags(:t1).k
76 tag.v = current_node_tags(:t1).v
77 assert tag.new_record?
79 assert_raise(ActiveRecord::RecordInvalid) {tag.save!}
80 assert tag.new_record?