1 require File.dirname(__FILE__) + '/../test_helper'
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 way = ways(:way_with_versions_v1)
42 tags = OldWay.find(way.id).old_tags.order(:k)
43 assert_equal 0, tags.count
45 way = ways(:way_with_versions_v2)
46 tags = OldWay.find(way.id).old_tags.order(:k)
47 assert_equal 0, tags.count
49 way = ways(:way_with_versions_v3)
50 tags = OldWay.find(way.id).old_tags.order(:k)
51 assert_equal 3, tags.count
52 assert_equal "testing", tags[0].k
53 assert_equal "added in way version 3", tags[0].v
54 assert_equal "testing three", tags[1].k
55 assert_equal "added in way version 3", tags[1].v
56 assert_equal "testing two", tags[2].k
57 assert_equal "added in way version 3", tags[2].v
59 way = ways(:way_with_versions_v4)
60 tags = OldWay.find(way.id).old_tags.order(:k)
61 assert_equal 2, tags.count
62 assert_equal "testing", tags[0].k
63 assert_equal "added in way version 3", tags[0].v
64 assert_equal "testing two", tags[1].k
65 assert_equal "modified in way version 4", tags[1].v
69 way = ways(:way_with_versions_v1)
70 tags = OldWay.find(way.id).tags
71 assert_equal 0, tags.size
73 way = ways(:way_with_versions_v2)
74 tags = OldWay.find(way.id).tags
75 assert_equal 0, tags.size
77 way = ways(:way_with_versions_v3)
78 tags = OldWay.find(way.id).tags
79 assert_equal 3, tags.size
80 assert_equal "added in way version 3", tags["testing"]
81 assert_equal "added in way version 3", tags["testing two"]
82 assert_equal "added in way version 3", tags["testing three"]
84 way = ways(:way_with_versions_v4)
85 tags = OldWay.find(way.id).tags
86 assert_equal 2, tags.size
87 assert_equal "added in way version 3", tags["testing"]
88 assert_equal "modified in way version 4", tags["testing two"]
91 def test_get_nodes_undelete
92 way = ways(:way_with_versions_v3)
93 nodes = OldWay.find(way.id).get_nodes_undelete
94 assert_equal 2, nodes.size
95 assert_equal [1.0, 1.0, 15, 4, {"testing" => "added in node version 3", "testing two" => "modified in node version 4"}, true], nodes[0]
96 assert_equal [3.0, 3.0, 3, 1, {"test" => "yes"}, true], nodes[1]
98 way = ways(:way_with_redacted_versions_v2)
99 nodes = OldWay.find(way.id).get_nodes_undelete
100 assert_equal 2, nodes.size
101 assert_equal [3.0, 3.0, 3, 1, {"test" => "yes"}, true], nodes[0]
102 assert_equal [2.0, 2.0, 2, 1, {"testused" => "yes"}, false], nodes[1]