]> git.openstreetmap.org Git - rails.git/blobdiff - test/unit/way_tag_test.rb
Add a paging control to the user blocks list
[rails.git] / test / unit / way_tag_test.rb
index 44b96ffe3a7951ff6b8e9386a77ee61621e336d3..b338f9c25801d8bc4b9522d17ad77d5e3043cc51 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
@@ -12,10 +11,10 @@ class WayTagTest < Test::Unit::TestCase
     key = "k"
     (0..255).each do |i|
       tag = WayTag.new
-      tag.id = current_way_tags(:t1).id
+      tag.way_id = current_way_tags(:t1).way_id
       tag.k = key*i
       tag.v = current_way_tags(:t1).v
-      assert_valid tag
+      assert tag.valid?
     end
   end
   
@@ -23,43 +22,44 @@ class WayTagTest < Test::Unit::TestCase
     val = "v"
     (0..255).each do |i|
       tag = WayTag.new
-      tag.id = current_way_tags(:t1).id
+      tag.way_id = current_way_tags(:t1).way_id
       tag.k = "k"
       tag.v = val*i
-      assert_valid tag
+      assert tag.valid?
     end
   end
   
   def test_length_key_invalid
     ["k"*256].each do |i|
       tag = WayTag.new
-      tag.id = current_way_tags(:t1).id
+      tag.way_id = current_way_tags(:t1).way_id
       tag.k = i
       tag.v = "v"
       assert !tag.valid?, "Key #{i} should be too long"
-      assert tag.errors.invalid?(:k)
+      assert tag.errors[:k].any?
     end
   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.way_id = current_way_tags(:t1).way_id
       tag.k = "k"
       tag.v = i
       assert !tag.valid?, "Value #{i} should be too long"
+      assert tag.errors[:v].any?
     end
   end
   
   def test_empty_tag_invalid
     tag = WayTag.new
     assert !tag.valid?, "Empty way tag should be invalid"
-    assert tag.errors.invalid?(:id)
+    assert tag.errors[:way].any?
   end
   
-  def test_uniquess
+  def test_uniqueness
     tag = WayTag.new
-    tag.id = current_way_tags(:t1).id
+    tag.way_id = current_way_tags(:t1).way_id
     tag.k = current_way_tags(:t1).k
     tag.v = current_way_tags(:t1).v
     assert tag.new_record?