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 3, 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 2, 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 3, tags.size
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 2, tags.size
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 nodes = OldWay.find(way.id).get_nodes_undelete
99 assert_equal 2, nodes.size
100 assert_equal [1.0, 1.0, 15, 4, { "testing" => "added in node version 3", "testing two" => "modified in node version 4" }, true], nodes[0]
101 assert_equal [3.0, 3.0, 3, 1, { "test" => "yes" }, true], nodes[1]
103 way = ways(:way_with_redacted_versions_v2)
104 nodes = OldWay.find(way.id).get_nodes_undelete
105 assert_equal 2, nodes.size
106 assert_equal [3.0, 3.0, 3, 1, { "test" => "yes" }, true], nodes[0]
107 assert_equal [2.0, 2.0, 2, 1, { "testused" => "yes" }, false], nodes[1]