1 require File.dirname(__FILE__) + '/../test_helper'
3 class RelationTagTest < Test::Unit::TestCase
4 fixtures :relation_tags
5 set_fixture_class :relation_tags => OldRelationTag
8 assert_equal 3, OldRlationTag.count
11 def test_length_key_valid
14 tag = OldRelationTag.new
15 tag.id = relation_tags(:t1).id
23 def test_length_value_valid
26 tag = OldRelationTag.new
27 tag.id = relation_tags(:t1).id
35 def test_length_key_invalid
37 tag = OldRelationTag.new
38 tag.id = relation_tags(:t1).id
42 assert !tag.valid?, "Key should be too long"
43 assert tag.errors.invalid?(:k)
47 def test_length_value_invalid
49 tag = OldRelationTag.new
50 tag.id = relation_tags(:t1).id
54 assert !tag.valid?, "Value should be too long"
55 assert tag.errors.invalid?(:v)
59 def test_empty_node_tag_invalid
60 tag = OldRelationTag.new
61 assert !tag.valid?, "Empty tag should be invalid"
62 assert tag.errors.invalid?(:id)
66 tag = OldRelationTag.new
67 tag.id = relation_tags(:t1).id
68 tag.version = relation_tags(:t1).version
69 tag.k = relation_tags(:t1).k
70 tag.v = relation_tags(:t1).v
71 assert tag.new_record?
73 assert_raise(ActiveRecord::RecordInvalid) {tag.save!}
74 assert tag.new_record?