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_v1 = create(:old_node, :version => 1)
51 node_v2 = create(:old_node, :node_id => node_v1.node_id, :version => 2)
52 node_v3 = create(:old_node, :node_id => node_v1.node_id, :version => 3)
53 node_v4 = create(:old_node, :node_id => node_v1.node_id, :version => 4)
54 taglist_v3 = create_list(:old_node_tag, 3, :old_node => node_v3)
55 taglist_v4 = create_list(:old_node_tag, 2, :old_node => node_v4)
58 tags = OldNode.find(node.id).old_tags.order(:k)
59 assert_equal 0, tags.count
62 tags = OldNode.find(node.id).old_tags.order(:k)
63 assert_equal 0, tags.count
66 tags = OldNode.find(node.id).old_tags.order(:k)
67 assert_equal taglist_v3.count, tags.count
68 taglist_v3.sort_by!(&:k).each_index do |i|
69 assert_equal taglist_v3[i].k, tags[i].k
70 assert_equal taglist_v3[i].v, tags[i].v
74 tags = OldNode.find(node.id).old_tags.order(:k)
75 assert_equal taglist_v4.count, tags.count
76 taglist_v4.sort_by!(&:k).each_index do |i|
77 assert_equal taglist_v4[i].k, tags[i].k
78 assert_equal taglist_v4[i].v, tags[i].v
83 node_v1 = create(:old_node, :version => 1)
84 node_v2 = create(:old_node, :node_id => node_v1.node_id, :version => 2)
85 node_v3 = create(:old_node, :node_id => node_v1.node_id, :version => 3)
86 node_v4 = create(:old_node, :node_id => node_v1.node_id, :version => 4)
87 taglist_v3 = create_list(:old_node_tag, 3, :old_node => node_v3)
88 taglist_v4 = create_list(:old_node_tag, 2, :old_node => node_v4)
91 tags = OldNode.find(node.id).tags
92 assert_equal 0, tags.size
95 tags = OldNode.find(node.id).tags
96 assert_equal 0, tags.size
99 tags = OldNode.find(node.id).tags
100 assert_equal taglist_v3.count, tags.count
101 taglist_v3.each do |tag|
102 assert_equal tag.v, tags[tag.k]
106 tags = OldNode.find(node.id).tags
107 assert_equal taglist_v4.count, tags.count
108 taglist_v4.each do |tag|
109 assert_equal tag.v, tags[tag.k]