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