1 require File.dirname(__FILE__) + '/../test_helper'
3 class ChangesetTagTest < Test::Unit::TestCase
4 fixtures :changeset_tags
6 def test_changeset_tag_count
7 assert_equal 1, ChangesetTag.count
10 def test_length_key_valid
13 tag = ChangesetTag.new
21 def test_length_value_valid
24 tag = ChangesetTag.new
32 def test_length_key_invalid
34 tag = ChangesetTag.new
38 assert !tag.valid?, "Key #{k} should be too long"
39 assert tag.errors.invalid?(:k)
43 def test_length_value_invalid
45 tag = ChangesetTag.new
49 assert !tag.valid?, "Value #{v} should be too long"
50 assert tag.errors.invalid?(:v)
54 def test_empty_tag_invalid
55 tag = ChangesetTag.new
56 assert !tag.valid?, "Empty tag should be invalid"
57 assert tag.errors.invalid?(:id)
61 tag = ChangesetTag.new
62 tag.id = changeset_tags(:changeset_1_tag_1).id
63 tag.k = changeset_tags(:changeset_1_tag_1).k
64 tag.v = changeset_tags(:changeset_1_tag_1).v
65 assert tag.new_record?
67 assert_raise(ActiveRecord::RecordInvalid) {tag.save!}
68 assert tag.new_record?