Give a nice error message when parsing the nwr tags and they are missing the k and...
[rails.git] / test / unit / way_tag_test.rb
index 44b96ffe3a7951ff6b8e9386a77ee61621e336d3..f5a931f6a322389744c93ff0e22254ba8ab36616 100644 (file)
@@ -1,8 +1,7 @@
 require File.dirname(__FILE__) + '/../test_helper'
 
-class WayTagTest < Test::Unit::TestCase
-  fixtures :current_way_tags
-  set_fixture_class :current_way_tags => WayTag
+class WayTagTest < ActiveSupport::TestCase
+  api_fixtures
   
   def test_way_tag_count
     assert_equal 3, WayTag.count
@@ -15,7 +14,7 @@ class WayTagTest < Test::Unit::TestCase
       tag.id = current_way_tags(:t1).id
       tag.k = key*i
       tag.v = current_way_tags(:t1).v
-      assert_valid tag
+      assert tag.valid?
     end
   end
   
@@ -26,7 +25,7 @@ class WayTagTest < Test::Unit::TestCase
       tag.id = current_way_tags(:t1).id
       tag.k = "k"
       tag.v = val*i
-      assert_valid tag
+      assert tag.valid?
     end
   end
   
@@ -42,12 +41,13 @@ class WayTagTest < Test::Unit::TestCase
   end
   
   def test_length_value_invalid
-    ["k"*256].each do |i|
+    ["v"*256].each do |i|
       tag = WayTag.new
       tag.id = current_way_tags(:t1).id
       tag.k = "k"
       tag.v = i
       assert !tag.valid?, "Value #{i} should be too long"
+      assert tag.errors.invalid?(:v)
     end
   end
   
@@ -57,7 +57,7 @@ class WayTagTest < Test::Unit::TestCase
     assert tag.errors.invalid?(:id)
   end
   
-  def test_uniquess
+  def test_uniqueness
     tag = WayTag.new
     tag.id = current_way_tags(:t1).id
     tag.k = current_way_tags(:t1).k