3 class OldRelationTagTest < ActiveSupport::TestCase
7 assert_equal 12, OldRelationTag.count
10 def test_length_key_valid
13 tag = OldRelationTag.new
14 tag.relation_id = relation_tags(:t1).relation_id
22 def test_length_value_valid
25 tag = OldRelationTag.new
26 tag.relation_id = relation_tags(:t1).relation_id
34 def test_length_key_invalid
36 tag = OldRelationTag.new
37 tag.relation_id = relation_tags(:t1).relation_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.relation_id = relation_tags(:t1).relation_id
53 assert !tag.valid?, "Value should be too long"
54 assert tag.errors[:v].any?
58 def test_empty_tag_invalid
59 tag = OldRelationTag.new
60 assert !tag.valid?, "Empty tag should be invalid"
61 assert tag.errors[:old_relation].any?
65 tag = OldRelationTag.new
66 tag.relation_id = relation_tags(:t1).relation_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?