]> git.openstreetmap.org Git - rails.git/blobdiff - test/unit/node_tag_test.rb
Refactoring the amf controller, and all models so that save_with_history! is now...
[rails.git] / test / unit / node_tag_test.rb
index fe6ebb166f2e949eade96120d3aa4a0a6fef43b7..2ff9f9f00563addb235919c6b25eae0f38f1ae59 100644 (file)
@@ -46,8 +46,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 +68,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