3 class WayTagTest < ActiveSupport::TestCase
4 def test_length_key_valid
8 assert_predicate tag, :valid?
12 def test_length_value_valid
13 tag = create(:way_tag)
16 assert_predicate tag, :valid?
20 def test_length_key_invalid
21 tag = create(:way_tag)
23 assert_not_predicate tag, :valid?, "Key should be too long"
24 assert_predicate tag.errors[:k], :any?
27 def test_length_value_invalid
28 tag = create(:way_tag)
30 assert_not_predicate tag, :valid?, "Value should be too long"
31 assert_predicate tag.errors[:v], :any?
34 def test_orphaned_tag_invalid
35 tag = create(:way_tag)
37 assert_not_predicate tag, :valid?, "Orphaned tag should be invalid"
38 assert_predicate tag.errors[:way], :any?
42 existing = create(:way_tag)
43 tag = build(:way_tag, :way => existing.way, :k => existing.k, :v => existing.v)
44 tag.way_id = existing.way_id
47 assert_predicate tag, :new_record?
48 assert_not_predicate tag, :valid?
49 assert_raise(ActiveRecord::RecordInvalid) { tag.save! }
50 assert_predicate tag, :new_record?