]> git.openstreetmap.org Git - rails.git/blobdiff - test/unit/old_relation_tag_test.rb
Add tests for tag methods on object models
[rails.git] / test / unit / old_relation_tag_test.rb
index aee2901cdfe8df7464506254447d9c465a20244d..faff45dd004b93e4dbeeb9fc1c11c6efbbfbf086 100644 (file)
@@ -1,21 +1,21 @@
 require File.dirname(__FILE__) + '/../test_helper'
 
-class OldRelationTagTest < Test::Unit::TestCase
+class OldRelationTagTest < ActiveSupport::TestCase
   api_fixtures
   
   def test_tag_count
-    assert_equal 3, OldRelationTag.count
+    assert_equal 12, OldRelationTag.count
   end
   
   def test_length_key_valid
     key = "k"
     (0..255).each do |i|
       tag = OldRelationTag.new
-      tag.id = relation_tags(:t1).id
+      tag.relation_id = relation_tags(:t1).relation_id
       tag.version = 1
       tag.k = key*i
       tag.v = "v"
-      assert_valid tag
+      assert tag.valid?
     end
   end
   
@@ -23,47 +23,47 @@ class OldRelationTagTest < Test::Unit::TestCase
     val = "v"
     (0..255).each do |i|
       tag = OldRelationTag.new
-      tag.id = relation_tags(:t1).id
+      tag.relation_id = relation_tags(:t1).relation_id
       tag.version = 1
       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 = OldRelationTag.new
-      tag.id = relation_tags(:t1).id
+      tag.relation_id = relation_tags(:t1).relation_id
       tag.version = 1
       tag.k = i
       tag.v = "v"
       assert !tag.valid?, "Key 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|
       tag = OldRelationTag.new
-      tag.id = relation_tags(:t1).id
+      tag.relation_id = relation_tags(:t1).relation_id
       tag.version = 1
       tag.k = "k"
       tag.v = i
       assert !tag.valid?, "Value should be too long"
-      assert tag.errors.invalid?(:v)
+      assert tag.errors[:v].any?
     end
   end
   
-  def test_empty_node_tag_invalid
+  def test_empty_tag_invalid
     tag = OldRelationTag.new
     assert !tag.valid?, "Empty tag should be invalid"
-    assert tag.errors.invalid?(:id)
+    assert tag.errors[:old_relation].any?
   end
   
   def test_uniqueness
     tag = OldRelationTag.new
-    tag.id = relation_tags(:t1).id
+    tag.relation_id = relation_tags(:t1).relation_id
     tag.version = relation_tags(:t1).version
     tag.k = relation_tags(:t1).k
     tag.v = relation_tags(:t1).v