]> git.openstreetmap.org Git - rails.git/blobdiff - test/unit/node_tag_test.rb
disabling test case because i don't think there is a fix with the current version...
[rails.git] / test / unit / node_tag_test.rb
index fe6ebb166f2e949eade96120d3aa4a0a6fef43b7..fe0f112bf32edd0c0e75d11672c0fb5e6cf653f8 100644 (file)
@@ -1,12 +1,10 @@
 require File.dirname(__FILE__) + '/../test_helper'
 
 class NodeTagTest < Test::Unit::TestCase
-  fixtures :current_node_tags, :current_nodes
-  set_fixture_class :current_nodes => Node
-  set_fixture_class :current_node_tags => NodeTag
+  api_fixtures
   
   def test_tag_count
-    assert_equal 6, NodeTag.count
+    assert_equal 7, NodeTag.count
     node_tag_count(:visible_node, 1)
     node_tag_count(:invisible_node, 1)
     node_tag_count(:used_node_1, 1)
@@ -46,8 +44,8 @@ class NodeTagTest < Test::Unit::TestCase
       tag = NodeTag.new
       tag.id = current_node_tags(:t1).id
       tag.k = i
-      tag.v = "v", "Key should be too long"
-      assert !tag.valid?
+      tag.v = "v"
+      assert !tag.valid?, "Key should be too long"
       assert tag.errors.invalid?(:k)
     end
   end
@@ -68,4 +66,15 @@ class NodeTagTest < Test::Unit::TestCase
     assert !tag.valid?, "Empty tag should be invalid"
     assert tag.errors.invalid?(:id)
   end
+  
+  def test_uniqueness
+    tag = NodeTag.new
+    tag.id = current_node_tags(:t1).id
+    tag.k = current_node_tags(:t1).k
+    tag.v = current_node_tags(:t1).v
+    assert tag.new_record?
+    assert !tag.valid?
+    assert_raise(ActiveRecord::RecordInvalid) {tag.save!}
+    assert tag.new_record?
+  end
 end