]> git.openstreetmap.org Git - rails.git/blob - test/models/old_relation_test.rb
Localisation updates from https://translatewiki.net.
[rails.git] / test / models / old_relation_test.rb
1 require "test_helper"
2
3 class OldRelationTest < ActiveSupport::TestCase
4   api_fixtures
5
6   def test_db_count
7     assert_equal 14, OldRelation.count
8   end
9
10   def test_relation_tags
11     relation = relations(:relation_with_versions_v1)
12     tags = OldRelation.find(relation.id).old_tags.order(:k)
13     assert_equal 0, tags.count
14
15     relation = relations(:relation_with_versions_v2)
16     tags = OldRelation.find(relation.id).old_tags.order(:k)
17     assert_equal 0, tags.count
18
19     relation = relations(:relation_with_versions_v3)
20     tags = OldRelation.find(relation.id).old_tags.order(:k)
21     assert_equal 3, tags.count
22     assert_equal "testing", tags[0].k
23     assert_equal "added in relation version 3", tags[0].v
24     assert_equal "testing three", tags[1].k
25     assert_equal "added in relation version 3", tags[1].v
26     assert_equal "testing two", tags[2].k
27     assert_equal "added in relation version 3", tags[2].v
28
29     relation = relations(:relation_with_versions_v4)
30     tags = OldRelation.find(relation.id).old_tags.order(:k)
31     assert_equal 2, tags.count
32     assert_equal "testing", tags[0].k
33     assert_equal "added in relation version 3", tags[0].v
34     assert_equal "testing two", tags[1].k
35     assert_equal "modified in relation version 4", tags[1].v
36   end
37
38   def test_relation_members
39     relation = relations(:relation_with_versions_v1)
40     members = OldRelation.find(relation.id).relation_members
41     assert_equal 1, members.count
42     assert_equal "some node", members[0].member_role
43     assert_equal "Node", members[0].member_type
44     assert_equal 15, members[0].member_id
45
46     relation = relations(:relation_with_versions_v2)
47     members = OldRelation.find(relation.id).relation_members
48     assert_equal 1, members.count
49     assert_equal "some changed node", members[0].member_role
50     assert_equal "Node", members[0].member_type
51     assert_equal 15, members[0].member_id
52
53     relation = relations(:relation_with_versions_v3)
54     members = OldRelation.find(relation.id).relation_members
55     assert_equal 2, members.count
56     assert_equal "some changed node", members[0].member_role
57     assert_equal "Node", members[0].member_type
58     assert_equal 15, members[0].member_id
59     assert_equal "some relation", members[1].member_role
60     assert_equal "Relation", members[1].member_type
61     assert_equal 7, members[1].member_id
62
63     relation = relations(:relation_with_versions_v4)
64     members = OldRelation.find(relation.id).relation_members
65     assert_equal 3, members.count
66     assert_equal "some node", members[0].member_role
67     assert_equal "Node", members[0].member_type
68     assert_equal 15, members[0].member_id
69     assert_equal "some way", members[1].member_role
70     assert_equal "Way", members[1].member_type
71     assert_equal 4, members[1].member_id
72     assert_equal "some relation", members[2].member_role
73     assert_equal "Relation", members[2].member_type
74     assert_equal 7, members[2].member_id
75   end
76
77   def test_relations
78     relation = relations(:relation_with_versions_v1)
79     members = OldRelation.find(relation.id).members
80     assert_equal 1, members.count
81     assert_equal ["Node", 15, "some node"], members[0]
82
83     relation = relations(:relation_with_versions_v2)
84     members = OldRelation.find(relation.id).members
85     assert_equal 1, members.count
86     assert_equal ["Node", 15, "some changed node"], members[0]
87
88     relation = relations(:relation_with_versions_v3)
89     members = OldRelation.find(relation.id).members
90     assert_equal 2, members.count
91     assert_equal ["Node", 15, "some changed node"], members[0]
92     assert_equal ["Relation", 7, "some relation"], members[1]
93
94     relation = relations(:relation_with_versions_v4)
95     members = OldRelation.find(relation.id).members
96     assert_equal 3, members.count
97     assert_equal ["Node", 15, "some node"], members[0]
98     assert_equal ["Way", 4, "some way"], members[1]
99     assert_equal ["Relation", 7, "some relation"], members[2]
100   end
101
102   def test_tags
103     relation = relations(:relation_with_versions_v1)
104     tags = OldRelation.find(relation.id).tags
105     assert_equal 0, tags.size
106
107     relation = relations(:relation_with_versions_v2)
108     tags = OldRelation.find(relation.id).tags
109     assert_equal 0, tags.size
110
111     relation = relations(:relation_with_versions_v3)
112     tags = OldRelation.find(relation.id).tags
113     assert_equal 3, tags.size
114     assert_equal "added in relation version 3", tags["testing"]
115     assert_equal "added in relation version 3", tags["testing two"]
116     assert_equal "added in relation version 3", tags["testing three"]
117
118     relation = relations(:relation_with_versions_v4)
119     tags = OldRelation.find(relation.id).tags
120     assert_equal 2, tags.size
121     assert_equal "added in relation version 3", tags["testing"]
122     assert_equal "modified in relation version 4", tags["testing two"]
123   end
124 end