From abb93de6276a5be229585e0010d71939c7160fec Mon Sep 17 00:00:00 2001 From: Shaun McDonald Date: Mon, 2 Jun 2008 17:27:32 +0000 Subject: [PATCH] Adding some additional node fixtures to test edge cases. Having a bit of an issue as the too far north and south tests aren't working as expected, even so the too far east and west ones are. --- test/fixtures/current_nodes.yml | 33 +++++++++++++++++++++++++++++++++ test/unit/node_test.rb | 29 ++++++++++++++++++++++++++++- 2 files changed, 61 insertions(+), 1 deletion(-) diff --git a/test/fixtures/current_nodes.yml b/test/fixtures/current_nodes.yml index fa9f6f711..35107d3d9 100644 --- a/test/fixtures/current_nodes.yml +++ b/test/fixtures/current_nodes.yml @@ -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 + diff --git a/test/unit/node_test.rb b/test/unit/node_test.rb index 876b23b69..fabd3ac42 100644 --- a/test/unit/node_test.rb +++ b/test/unit/node_test.rb @@ -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, -- 2.39.5