1 require File.dirname(__FILE__) + '/../test_helper'
3 class OldRelationTagTest < ActiveSupport::TestCase
7 assert_equal 7, OldRelationTag.count
10 def test_length_key_valid
13 tag = OldRelationTag.new
14 tag.id = relation_tags(:t1).id
22 def test_length_value_valid
25 tag = OldRelationTag.new
26 tag.id = relation_tags(:t1).id
34 def test_length_key_invalid
36 tag = OldRelationTag.new
37 tag.id = relation_tags(:t1).id
41 assert !tag.valid?, "Key should be too long"
42 assert tag.errors[:k].any?
46 def test_length_value_invalid
48 tag = OldRelationTag.new
49 tag.id = relation_tags(:t1).id
53 assert !tag.valid?, "Value should be too long"
54 assert tag.errors[:v].any?
58 def test_empty_node_tag_invalid
59 tag = OldRelationTag.new
60 assert !tag.valid?, "Empty tag should be invalid"
61 assert tag.errors[:id].any?
65 tag = OldRelationTag.new
66 tag.id = relation_tags(:t1).id
67 tag.version = relation_tags(:t1).version
68 tag.k = relation_tags(:t1).k
69 tag.v = relation_tags(:t1).v
70 assert tag.new_record?
72 assert_raise(ActiveRecord::RecordInvalid) {tag.save!}
73 assert tag.new_record?