3 class OldRelationTest < ActiveSupport::TestCase
7 assert_equal 14, OldRelation.count
10 def test_relation_tags
11 taglist_v3 = create_list(:old_relation_tag, 3, :old_relation => relations(:relation_with_versions_v3))
12 taglist_v4 = create_list(:old_relation_tag, 2, :old_relation => relations(:relation_with_versions_v4))
14 relation = relations(:relation_with_versions_v1)
15 tags = OldRelation.find(relation.id).old_tags.order(:k)
16 assert_equal 0, tags.count
18 relation = relations(:relation_with_versions_v2)
19 tags = OldRelation.find(relation.id).old_tags.order(:k)
20 assert_equal 0, tags.count
22 relation = relations(:relation_with_versions_v3)
23 tags = OldRelation.find(relation.id).old_tags.order(:k)
24 assert_equal taglist_v3.count, tags.count
25 taglist_v3.sort_by!(&:k).each_index do |i|
26 assert_equal taglist_v3[i].k, tags[i].k
27 assert_equal taglist_v3[i].v, tags[i].v
30 relation = relations(:relation_with_versions_v4)
31 tags = OldRelation.find(relation.id).old_tags.order(:k)
32 assert_equal taglist_v4.count, tags.count
33 taglist_v4.sort_by!(&:k).each_index do |i|
34 assert_equal taglist_v4[i].k, tags[i].k
35 assert_equal taglist_v4[i].v, tags[i].v
39 def test_relation_members
40 relation = relations(:relation_with_versions_v1)
41 members = OldRelation.find(relation.id).relation_members
42 assert_equal 1, members.count
43 assert_equal "some node", members[0].member_role
44 assert_equal "Node", members[0].member_type
45 assert_equal 15, members[0].member_id
47 relation = relations(:relation_with_versions_v2)
48 members = OldRelation.find(relation.id).relation_members
49 assert_equal 1, members.count
50 assert_equal "some changed node", members[0].member_role
51 assert_equal "Node", members[0].member_type
52 assert_equal 15, members[0].member_id
54 relation = relations(:relation_with_versions_v3)
55 members = OldRelation.find(relation.id).relation_members
56 assert_equal 2, members.count
57 assert_equal "some changed node", members[0].member_role
58 assert_equal "Node", members[0].member_type
59 assert_equal 15, members[0].member_id
60 assert_equal "some relation", members[1].member_role
61 assert_equal "Relation", members[1].member_type
62 assert_equal 7, members[1].member_id
64 relation = relations(:relation_with_versions_v4)
65 members = OldRelation.find(relation.id).relation_members
66 assert_equal 3, members.count
67 assert_equal "some node", members[0].member_role
68 assert_equal "Node", members[0].member_type
69 assert_equal 15, members[0].member_id
70 assert_equal "some way", members[1].member_role
71 assert_equal "Way", members[1].member_type
72 assert_equal 4, members[1].member_id
73 assert_equal "some relation", members[2].member_role
74 assert_equal "Relation", members[2].member_type
75 assert_equal 7, members[2].member_id
79 relation = relations(:relation_with_versions_v1)
80 members = OldRelation.find(relation.id).members
81 assert_equal 1, members.count
82 assert_equal ["Node", 15, "some node"], members[0]
84 relation = relations(:relation_with_versions_v2)
85 members = OldRelation.find(relation.id).members
86 assert_equal 1, members.count
87 assert_equal ["Node", 15, "some changed node"], members[0]
89 relation = relations(:relation_with_versions_v3)
90 members = OldRelation.find(relation.id).members
91 assert_equal 2, members.count
92 assert_equal ["Node", 15, "some changed node"], members[0]
93 assert_equal ["Relation", 7, "some relation"], members[1]
95 relation = relations(:relation_with_versions_v4)
96 members = OldRelation.find(relation.id).members
97 assert_equal 3, members.count
98 assert_equal ["Node", 15, "some node"], members[0]
99 assert_equal ["Way", 4, "some way"], members[1]
100 assert_equal ["Relation", 7, "some relation"], members[2]
104 taglist_v3 = create_list(:old_relation_tag, 3, :old_relation => relations(:relation_with_versions_v3))
105 taglist_v4 = create_list(:old_relation_tag, 2, :old_relation => relations(:relation_with_versions_v4))
107 relation = relations(:relation_with_versions_v1)
108 tags = OldRelation.find(relation.id).tags
109 assert_equal 0, tags.size
111 relation = relations(:relation_with_versions_v2)
112 tags = OldRelation.find(relation.id).tags
113 assert_equal 0, tags.size
115 relation = relations(:relation_with_versions_v3)
116 tags = OldRelation.find(relation.id).tags
117 assert_equal taglist_v3.count, tags.count
118 taglist_v3.each do |tag|
119 assert_equal tag.v, tags[tag.k]
122 relation = relations(:relation_with_versions_v4)
123 tags = OldRelation.find(relation.id).tags
124 assert_equal taglist_v4.count, tags.count
125 taglist_v4.each do |tag|
126 assert_equal tag.v, tags[tag.k]