3 class ChangesetTagTest < ActiveSupport::TestCase
4 def test_length_key_valid
5 changeset = create(:changeset)
10 tag.changeset_id = changeset.id
17 def test_length_value_valid
18 changeset = create(:changeset)
22 tag = ChangesetTag.new
23 tag.changeset_id = changeset.id
30 def test_length_key_invalid
31 ["k" * 256].each do |k|
32 tag = ChangesetTag.new
36 assert !tag.valid?, "Key #{k} should be too long"
37 assert tag.errors[:k].any?
41 def test_length_value_invalid
42 ["v" * 256].each do |v|
43 tag = ChangesetTag.new
47 assert !tag.valid?, "Value #{v} should be too long"
48 assert tag.errors[:v].any?
52 def test_empty_tag_invalid
53 tag = ChangesetTag.new
54 assert !tag.valid?, "Empty tag should be invalid"
55 assert tag.errors[:changeset].any?
59 existing = create(:changeset_tag)
60 tag = ChangesetTag.new
61 tag.changeset_id = existing.changeset_id
64 assert tag.new_record?
66 assert_raise(ActiveRecord::RecordInvalid) { tag.save! }
67 assert tag.new_record?