3 class OldWayTest < ActiveSupport::TestCase
7 assert_equal 14, OldWay.count
11 way = ways(:way_with_multiple_nodes_v1)
12 nodes = OldWay.find(way.id).old_nodes.order(:sequence_id)
13 assert_equal 2, nodes.count
14 assert_equal 2, nodes[0].node_id
15 assert_equal 6, nodes[1].node_id
17 way = ways(:way_with_multiple_nodes_v2)
18 nodes = OldWay.find(way.id).old_nodes.order(:sequence_id)
19 assert_equal 3, nodes.count
20 assert_equal 4, nodes[0].node_id
21 assert_equal 15, nodes[1].node_id
22 assert_equal 6, nodes[2].node_id
26 way = ways(:way_with_multiple_nodes_v1)
27 nodes = OldWay.find(way.id).nds
28 assert_equal 2, nodes.count
29 assert_equal 2, nodes[0]
30 assert_equal 6, nodes[1]
32 way = ways(:way_with_multiple_nodes_v2)
33 nodes = OldWay.find(way.id).nds
34 assert_equal 3, nodes.count
35 assert_equal 4, nodes[0]
36 assert_equal 15, nodes[1]
37 assert_equal 6, nodes[2]
41 taglist_v3 = create_list(:old_way_tag, 3, :old_way => ways(:way_with_versions_v3))
42 taglist_v4 = create_list(:old_way_tag, 2, :old_way => ways(:way_with_versions_v4))
44 way = ways(:way_with_versions_v1)
45 tags = OldWay.find(way.id).old_tags.order(:k)
46 assert_equal 0, tags.count
48 way = ways(:way_with_versions_v2)
49 tags = OldWay.find(way.id).old_tags.order(:k)
50 assert_equal 0, tags.count
52 way = ways(:way_with_versions_v3)
53 tags = OldWay.find(way.id).old_tags.order(:k)
54 assert_equal taglist_v3.count, tags.count
55 taglist_v3.sort_by!(&:k).each_index do |i|
56 assert_equal taglist_v3[i].k, tags[i].k
57 assert_equal taglist_v3[i].v, tags[i].v
60 way = ways(:way_with_versions_v4)
61 tags = OldWay.find(way.id).old_tags.order(:k)
62 assert_equal taglist_v4.count, tags.count
63 taglist_v4.sort_by!(&:k).each_index do |i|
64 assert_equal taglist_v4[i].k, tags[i].k
65 assert_equal taglist_v4[i].v, tags[i].v
70 taglist_v3 = create_list(:old_way_tag, 3, :old_way => ways(:way_with_versions_v3))
71 taglist_v4 = create_list(:old_way_tag, 2, :old_way => ways(:way_with_versions_v4))
73 way = ways(:way_with_versions_v1)
74 tags = OldWay.find(way.id).tags
75 assert_equal 0, tags.size
77 way = ways(:way_with_versions_v2)
78 tags = OldWay.find(way.id).tags
79 assert_equal 0, tags.size
81 way = ways(:way_with_versions_v3)
82 tags = OldWay.find(way.id).tags
83 assert_equal taglist_v3.count, tags.count
84 taglist_v3.each do |tag|
85 assert_equal tag.v, tags[tag.k]
88 way = ways(:way_with_versions_v4)
89 tags = OldWay.find(way.id).tags
90 assert_equal taglist_v4.count, tags.count
91 taglist_v4.each do |tag|
92 assert_equal tag.v, tags[tag.k]
96 def test_get_nodes_undelete
97 way = ways(:way_with_versions_v3)
98 node_tag = create(:node_tag, :node => current_nodes(:node_with_versions))
99 node_tag2 = create(:node_tag, :node => current_nodes(:used_node_1))
100 nodes = OldWay.find(way.id).get_nodes_undelete
101 assert_equal 2, nodes.size
102 assert_equal [1.0, 1.0, 15, 4, { node_tag.k => node_tag.v }, true], nodes[0]
103 assert_equal [3.0, 3.0, 3, 1, { node_tag2.k => node_tag2.v }, true], nodes[1]
105 way = ways(:way_with_redacted_versions_v2)
106 node_tag3 = create(:node_tag, :node => current_nodes(:invisible_node))
107 nodes = OldWay.find(way.id).get_nodes_undelete
108 assert_equal 2, nodes.size
109 assert_equal [3.0, 3.0, 3, 1, { node_tag2.k => node_tag2.v }, true], nodes[0]
110 assert_equal [2.0, 2.0, 2, 1, { node_tag3.k => node_tag3.v }, false], nodes[1]