1 require File.dirname(__FILE__) + '/../test_helper'
3 class WayTagTest < Test::Unit::TestCase
4 fixtures :current_way_tags
5 set_fixture_class :current_way_tags => WayTag
8 assert_equal 3, WayTag.count
11 def test_length_key_valid
15 tag.id = current_way_tags(:t1).id
17 tag.v = current_way_tags(:t1).v
22 def test_length_value_valid
26 tag.id = current_way_tags(:t1).id
33 def test_length_key_invalid
36 tag.id = current_way_tags(:t1).id
39 assert !tag.valid?, "Key #{i} should be too long"
40 assert tag.errors.invalid?(:k)
44 def test_length_value_invalid
47 tag.id = current_way_tags(:t1).id
50 assert !tag.valid?, "Value #{i} should be too long"
51 assert tag.errors.invalid?(:v)
55 def test_empty_tag_invalid
57 assert !tag.valid?, "Empty way tag should be invalid"
58 assert tag.errors.invalid?(:id)
63 tag.id = current_way_tags(:t1).id
64 tag.k = current_way_tags(:t1).k
65 tag.v = current_way_tags(:t1).v
66 assert tag.new_record?
68 assert_raise(ActiveRecord::RecordInvalid) {tag.save!}
69 assert tag.new_record?