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
+
require File.dirname(__FILE__) + '/../test_helper'
+require 'Node'
class NodeTest < Test::Unit::TestCase
fixtures :current_nodes, :nodes, :users, :current_node_tags, :node_tags
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,