1 require File.dirname(__FILE__) + '/../test_helper'
3 class ChangesetTagTest < ActiveSupport::TestCase
6 def test_changeset_tag_count
7 assert_equal 2, 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[:k].any?
43 def test_length_value_invalid
45 tag = ChangesetTag.new
49 assert !tag.valid?, "Value #{v} should be too long"
50 assert tag.errors[:v].any?
54 def test_empty_tag_invalid
55 tag = ChangesetTag.new
56 assert !tag.valid?, "Empty tag should be invalid"
57 assert tag.errors[:changeset].any?
61 tag = ChangesetTag.new
62 tag.changeset_id = changeset_tags(:changeset_1_tag_1).changeset_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?