3 class WayTagTest < ActiveSupport::TestCase
7 assert_equal 5, WayTag.count
10 def test_length_key_valid
14 tag.way_id = current_way_tags(:t1).way_id
16 tag.v = current_way_tags(:t1).v
21 def test_length_value_valid
25 tag.way_id = current_way_tags(:t1).way_id
32 def test_length_key_invalid
33 ["k" * 256].each do |i|
35 tag.way_id = current_way_tags(:t1).way_id
38 assert !tag.valid?, "Key #{i} should be too long"
39 assert tag.errors[:k].any?
43 def test_length_value_invalid
44 ["v" * 256].each do |i|
46 tag.way_id = current_way_tags(:t1).way_id
49 assert !tag.valid?, "Value #{i} should be too long"
50 assert tag.errors[:v].any?
54 def test_empty_tag_invalid
56 assert !tag.valid?, "Empty way tag should be invalid"
57 assert tag.errors[:way].any?
62 tag.way_id = current_way_tags(:t1).way_id
63 tag.k = current_way_tags(:t1).k
64 tag.v = current_way_tags(:t1).v
65 assert tag.new_record?
67 assert_raise(ActiveRecord::RecordInvalid) { tag.save! }
68 assert tag.new_record?