3 class OldNodeTest < ActiveSupport::TestCase
4 def test_node_too_far_north
5 node = build(:old_node, :latitude => 90.01 * OldNode::SCALE)
6 assert_equal false, node.valid?
9 def test_node_north_limit
10 node = build(:old_node, :latitude => 90 * OldNode::SCALE)
14 def test_node_too_far_south
15 node = build(:old_node, :latitude => -90.01 * OldNode::SCALE)
16 assert_equal false, node.valid?
19 def test_node_south_limit
20 node = build(:old_node, :latitude => -90 * OldNode::SCALE)
24 def test_node_too_far_west
25 node = build(:old_node, :longitude => -180.01 * OldNode::SCALE)
26 assert_equal false, node.valid?
29 def test_node_west_limit
30 node = build(:old_node, :longitude => -180 * OldNode::SCALE)
34 def test_node_too_far_east
35 node = build(:old_node, :longitude => 180.01 * OldNode::SCALE)
36 assert_equal false, node.valid?
39 def test_node_east_limit
40 node = build(:old_node, :longitude => 180 * OldNode::SCALE)
44 def test_totally_wrong
45 node = build(:old_node, :latitude => 200 * OldNode::SCALE, :longitude => 200 * OldNode::SCALE)
46 assert_equal false, node.valid?
50 node = build(:old_node, :latitude => 12.345 * OldNode::SCALE, :longitude => 34.567 * OldNode::SCALE)
52 assert_in_delta 12.345, node.lat, 0.0000001
53 assert_in_delta 34.567, node.lon, 0.0000001
58 assert_in_delta 54.321 * OldNode::SCALE, node.latitude, 0.000001
59 assert_in_delta 76.543 * OldNode::SCALE, node.longitude, 0.000001
63 node_v1 = create(:old_node, :version => 1)
64 node_v2 = create(:old_node, :node_id => node_v1.node_id, :version => 2)
65 node_v3 = create(:old_node, :node_id => node_v1.node_id, :version => 3)
66 node_v4 = create(:old_node, :node_id => node_v1.node_id, :version => 4)
67 taglist_v3 = create_list(:old_node_tag, 3, :old_node => node_v3)
68 taglist_v4 = create_list(:old_node_tag, 2, :old_node => node_v4)
71 tags = OldNode.find(node.id).old_tags.order(:k)
72 assert_equal 0, tags.count
75 tags = OldNode.find(node.id).old_tags.order(:k)
76 assert_equal 0, tags.count
79 tags = OldNode.find(node.id).old_tags.order(:k)
80 assert_equal taglist_v3.count, tags.count
81 taglist_v3.sort_by!(&:k).each_index do |i|
82 assert_equal taglist_v3[i].k, tags[i].k
83 assert_equal taglist_v3[i].v, tags[i].v
87 tags = OldNode.find(node.id).old_tags.order(:k)
88 assert_equal taglist_v4.count, tags.count
89 taglist_v4.sort_by!(&:k).each_index do |i|
90 assert_equal taglist_v4[i].k, tags[i].k
91 assert_equal taglist_v4[i].v, tags[i].v
96 node_v1 = create(:old_node, :version => 1)
97 node_v2 = create(:old_node, :node_id => node_v1.node_id, :version => 2)
98 node_v3 = create(:old_node, :node_id => node_v1.node_id, :version => 3)
99 node_v4 = create(:old_node, :node_id => node_v1.node_id, :version => 4)
100 taglist_v3 = create_list(:old_node_tag, 3, :old_node => node_v3)
101 taglist_v4 = create_list(:old_node_tag, 2, :old_node => node_v4)
104 tags = OldNode.find(node.id).tags
105 assert_equal 0, tags.size
108 tags = OldNode.find(node.id).tags
109 assert_equal 0, tags.size
112 tags = OldNode.find(node.id).tags
113 assert_equal taglist_v3.count, tags.count
114 taglist_v3.each do |tag|
115 assert_equal tag.v, tags[tag.k]
119 tags = OldNode.find(node.id).tags
120 assert_equal taglist_v4.count, tags.count
121 taglist_v4.each do |tag|
122 assert_equal tag.v, tags[tag.k]