Unit tests work again. Fixed the set fixture class that I should. Adding 2 length...
authorShaun McDonald <shaun@shaunmcdonald.me.uk>
Fri, 14 Nov 2008 16:26:56 +0000 (16:26 +0000)
committerShaun McDonald <shaun@shaunmcdonald.me.uk>
Fri, 14 Nov 2008 16:26:56 +0000 (16:26 +0000)
test/unit/user_preference_test.rb
test/unit/way_node_test.rb
test/unit/way_tag_test.rb

index d591db69d5d0ce35fac9dfeafd829dcab5225b8d..2118fcd395df252d0c40d6cc6188cb35109b650c 100644 (file)
@@ -22,5 +22,33 @@ class UserPreferenceTest < ActiveSupport::TestCase
     assert_raise (ActiveRecord::StatementInvalid) {newUP.save}
   end
   
+  def test_check_valid_length
+    key = "k"
+    val = "v"
+    (1..255).each do |i|
+      up = UserPreference.new
+      up.user = users(:normal_user)
+      up.k = key*i
+      up.v = val*i
+      assert up.valid?
+      assert up.save!
+      resp = UserPreference.find(up.id)
+      assert_equal key*i, resp.k, "User preference with #{i} #{key} chars (i.e. #{key.length*i} bytes) fails"
+      assert_equal val*i, resp.v, "User preference with #{i} #{val} chars (i.e. #{val.length*i} bytes) fails"
+    end
+  end
+  
+  def test_check_invalid_length
+    key = "k"
+    val = "v"
+    [0,256].each do |i|
+      up = UserPreference.new
+      up.user = users(:normal_user)
+      up.k = key*i
+      up.v = val*i
+      assert_equal false, up.valid?
+      assert_raise(ActiveRecord::RecordInvalid) {up.save!}
+    end
+  end
 
 end
index b931d3c04001192b55fcaded7ed05a33c6cd8e59..1871eae9d9c7437923c92bfb3172ffc7322d4b66 100644 (file)
@@ -1,7 +1,7 @@
 require File.dirname(__FILE__) + '/../test_helper'
 
 class WayNodeTest < Test::Unit::TestCase
-  fixtures :way_nodes
+  fixtures :way_nodes, :current_way_nodes
   set_fixture_class :way_nodes=>OldWayNode
   set_fixture_class :current_way_nodes=>WayNode
   
index 099d29da39fc08fe1728c0769623aad3810dc401..cd296749e9abf3d154895be8a5aac21a037157ef 100644 (file)
@@ -1,8 +1,8 @@
 require File.dirname(__FILE__) + '/../test_helper'
 
 class WayTagTest < Test::Unit::TestCase
-  fixtures :way_tags
-  
+  fixtures :current_way_tags
+  set_fixture_class :current_way_tags => WayTag
   
   def test_way_tag_count
     assert_equal 3, WayTag.count