]> git.openstreetmap.org Git - rails.git/blobdiff - test/unit/relation_tag_test.rb
fix the user unit test so that it doesn't use a depricated method in rails 2.2.2
[rails.git] / test / unit / relation_tag_test.rb
index 5c008fc34c415759dc2e8bda5f2819177e207416..e091efb0f27e36ba5857beceb1d1bbcc33fd6e18 100644 (file)
@@ -4,7 +4,7 @@ class RelationTagTest < Test::Unit::TestCase
   api_fixtures
   
   def test_relation_tag_count
-    assert_equal 3, RelationTag.count
+    assert_equal 7, RelationTag.count
   end
   
   def test_length_key_valid
@@ -67,4 +67,22 @@ class RelationTagTest < Test::Unit::TestCase
     assert_raise(ActiveRecord::RecordInvalid) {tag.save!}
     assert tag.new_record?
   end
+
+  ##
+  # test that tags can be updated and saved uniquely, i.e: tag.save!
+  # only affects the single tag that the activerecord object 
+  # represents. this amounts to testing that the primary key is
+  # unique.
+  def test_update
+    v = "probably unique string here 3142592654"
+    assert_equal 0, RelationTag.count(:conditions => ['v=?', v])
+
+    # make sure we select a tag on a relation which has more than one tag
+    id = current_relations(:multi_tag_relation).id
+    tag = RelationTag.find(:first, :conditions => ["id = ?", id])
+    tag.v = v
+    tag.save!
+
+    assert_equal 1, RelationTag.count(:conditions => ['v=?', v])
+  end
 end