]> git.openstreetmap.org Git - rails.git/commitdiff
Adding some additional node fixtures to test edge cases. Having a bit of an issue...
authorShaun McDonald <shaun@shaunmcdonald.me.uk>
Mon, 2 Jun 2008 17:27:32 +0000 (17:27 +0000)
committerShaun McDonald <shaun@shaunmcdonald.me.uk>
Mon, 2 Jun 2008 17:27:32 +0000 (17:27 +0000)
test/fixtures/current_nodes.yml
test/unit/node_test.rb

index fa9f6f71114012616b1aa953e9aaaa2a57686cb7..35107d3d91d7b7524fe9afa85e32fb151faa2771 100644 (file)
@@ -38,3 +38,36 @@ node_used_by_relationship:
   user_id: 1
   visible: 1
   timestamp: 2007-01-01 00:00:00
+  
+node_too_far_north:
+  id: 6
+  latitude: 92
+  longitude: 6
+  user_id: 1
+  timestamp: 2008-05-02 00:00:00
+  
+node_too_far_south:
+  id: 7
+  latitude: -92
+  longitude: 7
+  user_id: 1
+  timestamp: 2008-05-02 00:00:00
+  
+node_too_far_west:
+  id: 8
+  latitude: 8
+  longitude: -180
+  user_id: 1
+  
+node_too_far_east:
+  id: 9
+  latitude: 9
+  longitude: 180
+  user_id: 1
+  
+node_totally_wrong:
+  id: 10
+  latitude: 1000
+  longitude: 1000
+  user_id: 1
+  
index 876b23b6940efce67e48e75ea52983797a8df1f3..fabd3ac420dbe347a7f7b75d8c0d19113f973982 100644 (file)
@@ -1,4 +1,5 @@
 require File.dirname(__FILE__) + '/../test_helper'
+require 'Node'
 
 class NodeTest < Test::Unit::TestCase
   fixtures :current_nodes, :nodes, :users, :current_node_tags, :node_tags
@@ -6,7 +7,33 @@ class NodeTest < Test::Unit::TestCase
   set_fixture_class :nodes => :OldNode
   set_fixture_class :node_tags => :OldNodeTag
   set_fixture_class :currenr_node_tags => :NodeTag
-
+    
+  def test_node_too_far_north
+    node = current_nodes(:node_too_far_north)
+    assert !node.valid?
+    assert node.error.invalid?(:latitude)
+  end
+  
+  def test_node_too_far_south
+    node = current_nodes(:node_too_far_south)
+    assert !node.valid?
+  end
+  
+  def test_node_too_far_west
+    node = current_nodes(:node_too_far_west)
+    assert !node.valid?
+  end
+  
+  def test_node_too_far_east
+    node = current_nodes(:node_too_far_east)
+    assert !node.valid?
+  end
+  
+  def test_totally_wrong
+    node = current_nodes(:node_totally_wrong)
+    assert !node.valid?
+  end
+  
   def test_create
     node_template = Node.new(:latitude => 12.3456,
                              :longitude => 65.4321,