]> git.openstreetmap.org Git - rails.git/blob - test/unit/way_test.rb
removing debug statement
[rails.git] / test / unit / way_test.rb
1 require File.dirname(__FILE__) + '/../test_helper'
2
3 class WayTest < Test::Unit::TestCase
4   api_fixtures
5
6   
7   # Check that we have the correct number of currnet ways in the db
8   # This will need to updated whenever the current_ways.yml is updated
9   def test_db_count
10     assert_equal 4, Way.count
11   end
12   
13   def test_bbox
14     node = current_nodes(:used_node_1)
15     [ :visible_way,
16       :invisible_way,
17       :used_way ].each do |way_symbol|
18       way = current_ways(way_symbol)
19       assert_equal node.bbox, way.bbox
20     end
21   end
22   
23   # Check that the preconditions fail when you are over the defined limit of 
24   # the maximum number of nodes in each way.
25   def test_max_nodes_per_way_limit
26     # Take one of the current ways and add nodes to it until we are near the limit
27     way = Way.find(current_ways(:visible_way).id)
28     assert way.valid?
29     # it already has 1 node
30     1.upto((APP_CONFIG['max_number_of_way_nodes'])/2) {
31       way.add_nd_num(current_nodes(:used_node_1).id)
32       way.add_nd_num(current_nodes(:used_node_2).id)
33     }
34     way.save
35     #print way.nds.size
36     assert way.valid?
37     way.add_nd_num(current_nodes(:visible_node).id)
38     assert way.valid?
39   end
40 end