3 class ChangesetTagTest < ActiveSupport::TestCase
6 def test_length_key_valid
17 def test_length_value_valid
20 tag = ChangesetTag.new
28 def test_length_key_invalid
29 ["k" * 256].each do |k|
30 tag = ChangesetTag.new
34 assert !tag.valid?, "Key #{k} should be too long"
35 assert tag.errors[:k].any?
39 def test_length_value_invalid
40 ["v" * 256].each do |v|
41 tag = ChangesetTag.new
45 assert !tag.valid?, "Value #{v} should be too long"
46 assert tag.errors[:v].any?
50 def test_empty_tag_invalid
51 tag = ChangesetTag.new
52 assert !tag.valid?, "Empty tag should be invalid"
53 assert tag.errors[:changeset].any?
57 existing = create(:changeset_tag)
58 tag = ChangesetTag.new
59 tag.changeset_id = existing.changeset_id
62 assert tag.new_record?
64 assert_raise(ActiveRecord::RecordInvalid) { tag.save! }
65 assert tag.new_record?