1 require "application_system_test_case"
3 class ElementCurrentVersionTest < ApplicationSystemTestCase
4 test "shows a node with one version" do
5 node = create(:node, :lat => 60, :lon => 30)
10 assert_css "h2", :text => "Node: #{node.id}"
11 within "h4", :text => "Version #1" do
12 assert_link "1", :href => old_node_path(node, 1)
14 assert_text(/Location: 60\.\d+, 30\.\d+/)
15 assert_no_text "Deleted"
17 assert_link "Download XML", :href => api_node_path(node)
18 assert_link "History", :exact => true, :href => node_history_path(node)
19 assert_no_link "Unredacted History"
23 test "shows a way with one version" do
29 assert_css "h2", :text => "Way: #{way.id}"
30 within "h4", :text => "Version #1" do
31 assert_link "1", :href => old_way_path(way, 1)
33 assert_no_text "Deleted"
35 assert_link "Download XML", :href => api_way_path(way)
36 assert_link "History", :exact => true, :href => way_history_path(way)
37 assert_no_link "Unredacted History"
41 test "shows a relation with one version" do
42 relation = create(:relation)
44 visit relation_path(relation)
47 assert_css "h2", :text => "Relation: #{relation.id}"
48 within "h4", :text => "Version #1" do
49 assert_link "1", :href => old_relation_path(relation, 1)
51 assert_no_text "Deleted"
53 assert_link "Download XML", :href => api_relation_path(relation)
54 assert_link "History", :exact => true, :href => relation_history_path(relation)
55 assert_no_link "Unredacted History"
59 test "shows a node with two versions" do
60 node = create(:node, :with_history, :lat => 60, :lon => 30, :version => 2)
65 assert_css "h2", :text => "Node: #{node.id}"
66 within "h4", :text => "Version #2" do
67 assert_link "2", :href => old_node_path(node, 2)
69 assert_text(/Location: 60\.\d+, 30\.\d+/)
70 assert_no_text "Deleted"
72 assert_link "Download XML", :href => api_node_path(node)
73 assert_link "History", :exact => true, :href => node_history_path(node)
74 assert_no_link "Unredacted History"
75 assert_link "Version #1", :href => old_node_path(node, 1)
76 assert_link "Version #2", :href => old_node_path(node, 2)
80 test "shows a way with two versions" do
81 way = create(:way, :version => 2)
86 assert_css "h2", :text => "Way: #{way.id}"
87 within "h4", :text => "Version #2" do
88 assert_link "2", :href => old_way_path(way, 2)
90 assert_no_text "Deleted"
92 assert_link "Download XML", :href => api_way_path(way)
93 assert_link "History", :exact => true, :href => way_history_path(way)
94 assert_no_link "Unredacted History"
95 assert_link "Version #1", :href => old_way_path(way, 1)
96 assert_link "Version #2", :href => old_way_path(way, 2)
100 test "shows a relation with two versions" do
101 relation = create(:relation, :version => 2)
103 visit relation_path(relation)
106 assert_css "h2", :text => "Relation: #{relation.id}"
107 within "h4", :text => "Version #2" do
108 assert_link "2", :href => old_relation_path(relation, 2)
110 assert_no_text "Deleted"
112 assert_link "Download XML", :href => api_relation_path(relation)
113 assert_link "History", :exact => true, :href => relation_history_path(relation)
114 assert_no_link "Unredacted History"
115 assert_link "Version #1", :href => old_relation_path(relation, 1)
116 assert_link "Version #2", :href => old_relation_path(relation, 2)
120 test "shows a deleted node" do
121 node = create(:node, :with_history, :lat => 60, :lon => 30, :visible => false, :version => 2)
123 visit node_path(node)
126 assert_css "h2", :text => "Node: #{node.id}"
127 within "h4", :text => "Version #2" do
128 assert_link "2", :href => old_node_path(node, 2)
130 assert_no_text "Location"
131 assert_text "Deleted"
133 assert_no_link "Download XML"
134 assert_link "History", :exact => true, :href => node_history_path(node)
135 assert_no_link "Unredacted History"
139 test "shows a deleted way" do
140 way = create(:way, :visible => false, :version => 2)
145 assert_css "h2", :text => "Way: #{way.id}"
146 within "h4", :text => "Version #2" do
147 assert_link "2", :href => old_way_path(way, 2)
149 assert_text "Deleted"
151 assert_no_link "Download XML"
152 assert_link "History", :exact => true, :href => way_history_path(way)
153 assert_no_link "Unredacted History"
157 test "shows a deleted relation" do
158 relation = create(:relation, :visible => false, :version => 2)
160 visit relation_path(relation)
163 assert_css "h2", :text => "Relation: #{relation.id}"
164 within "h4", :text => "Version #2" do
165 assert_link "2", :href => old_relation_path(relation, 2)
167 assert_text "Deleted"
169 assert_no_link "Download XML"
170 assert_link "History", :exact => true, :href => relation_history_path(relation)
171 assert_no_link "Unredacted History"
175 test "shows node navigation to regular users" do
176 node = create(:node, :with_history)
178 sign_in_as(create(:user))
179 visit node_path(node)
182 assert_link "History", :exact => true, :href => node_history_path(node)
183 assert_no_link "Unredacted History"
187 test "shows way navigation to regular users" do
188 way = create(:way, :with_history)
190 sign_in_as(create(:user))
194 assert_link "History", :exact => true, :href => way_history_path(way)
195 assert_no_link "Unredacted History"
199 test "shows relation navigation to regular users" do
200 relation = create(:relation, :with_history)
202 sign_in_as(create(:user))
203 visit relation_path(relation)
206 assert_link "History", :exact => true, :href => relation_history_path(relation)
207 assert_no_link "Unredacted History"
211 test "shows node navigation to moderators" do
212 node = create(:node, :with_history)
214 sign_in_as(create(:moderator_user))
215 visit node_path(node)
218 assert_link "History", :exact => true, :href => node_history_path(node)
219 assert_link "Unredacted History", :href => node_history_path(node, :show_redactions => true)
223 test "shows way navigation to moderators" do
224 way = create(:way, :with_history)
226 sign_in_as(create(:moderator_user))
230 assert_link "History", :exact => true, :href => way_history_path(way)
231 assert_link "Unredacted History", :href => way_history_path(way, :show_redactions => true)
235 test "shows relation navigation to moderators" do
236 relation = create(:relation, :with_history)
238 sign_in_as(create(:moderator_user))
239 visit relation_path(relation)
242 assert_link "History", :exact => true, :href => relation_history_path(relation)
243 assert_link "Unredacted History", :href => relation_history_path(relation, :show_redactions => true)
247 test "shows a link to containing relation of a node" do
249 containing_relation = create(:relation)
250 create(:relation_member, :relation => containing_relation, :member => node)
252 visit node_path(node)
255 assert_link :href => relation_path(containing_relation)
259 test "shows a link to containing relation of a way" do
261 containing_relation = create(:relation)
262 create(:relation_member, :relation => containing_relation, :member => way)
267 assert_link :href => relation_path(containing_relation)
271 test "shows a link to containing relation of a relation" do
272 relation = create(:relation)
273 containing_relation = create(:relation)
274 create(:relation_member, :relation => containing_relation, :member => relation)
276 visit relation_path(relation)
279 assert_link :href => relation_path(containing_relation)
283 test "relation member nodes should be visible on the map when viewing relations" do
284 relation = create(:relation)
286 create(:relation_member, :relation => relation, :member => node)
288 visit relation_path(relation)
290 assert_selector "#map .leaflet-overlay-pane path"
293 test "map should center on a viewed node" do
294 node = create(:node, :lat => 59.55555, :lon => 29.55555)
296 visit node_path(node)
302 share_url = find_by_id("long_input").value
303 assert_match %r{map=\d+/59\.\d+/29\.\d+}, share_url