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 "View History", :href => node_history_path(node)
19 assert_no_link "View 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 "View History", :href => way_history_path(way)
37 assert_no_link "View Unredacted History"
41 test "shows a node with two versions" do
42 node = create(:node, :with_history, :lat => 60, :lon => 30, :version => 2)
47 assert_css "h2", :text => "Node: #{node.id}"
48 within "h4", :text => "Version #2" do
49 assert_link "2", :href => old_node_path(node, 2)
51 assert_text(/Location: 60\.\d+, 30\.\d+/)
52 assert_no_text "Deleted"
54 assert_link "Download XML", :href => api_node_path(node)
55 assert_link "View History", :href => node_history_path(node)
56 assert_no_link "View Unredacted History"
57 assert_link "Version #1", :href => old_node_path(node, 1)
58 assert_link "Version #2", :href => old_node_path(node, 2)
62 test "shows a way with two versions" do
63 way = create(:way, :version => 2)
68 assert_css "h2", :text => "Way: #{way.id}"
69 within "h4", :text => "Version #2" do
70 assert_link "2", :href => old_way_path(way, 2)
72 assert_no_text "Deleted"
74 assert_link "Download XML", :href => api_way_path(way)
75 assert_link "View History", :href => way_history_path(way)
76 assert_no_link "View Unredacted History"
77 assert_link "Version #1", :href => old_way_path(way, 1)
78 assert_link "Version #2", :href => old_way_path(way, 2)
82 test "shows a deleted node" do
83 node = create(:node, :with_history, :lat => 60, :lon => 30, :visible => false, :version => 2)
88 assert_css "h2", :text => "Node: #{node.id}"
89 within "h4", :text => "Version #2" do
90 assert_link "2", :href => old_node_path(node, 2)
92 assert_no_text "Location"
95 assert_no_link "Download XML"
96 assert_link "View History", :href => node_history_path(node)
97 assert_no_link "View Unredacted History"
101 test "shows a deleted way" do
102 way = create(:way, :visible => false, :version => 2)
107 assert_css "h2", :text => "Way: #{way.id}"
108 within "h4", :text => "Version #2" do
109 assert_link "2", :href => old_way_path(way, 2)
111 assert_text "Deleted"
113 assert_no_link "Download XML"
114 assert_link "View History", :href => way_history_path(way)
115 assert_no_link "View Unredacted History"
119 test "shows node navigation to regular users" do
120 node = create(:node, :with_history)
122 sign_in_as(create(:user))
123 visit node_path(node)
126 assert_link "View History", :href => node_history_path(node)
127 assert_no_link "View Unredacted History"
131 test "shows way navigation to regular users" do
132 way = create(:way, :with_history)
134 sign_in_as(create(:user))
138 assert_link "View History", :href => way_history_path(way)
139 assert_no_link "View Unredacted History"
143 test "shows node navigation to moderators" do
144 node = create(:node, :with_history)
146 sign_in_as(create(:moderator_user))
147 visit node_path(node)
150 assert_link "View History", :href => node_history_path(node)
151 assert_link "View Unredacted History", :href => node_history_path(node, :show_redactions => true)
155 test "shows way navigation to moderators" do
156 way = create(:way, :with_history)
158 sign_in_as(create(:moderator_user))
162 assert_link "View History", :href => way_history_path(way)
163 assert_link "View Unredacted History", :href => way_history_path(way, :show_redactions => true)
167 test "shows a link to containing relation of a node" do
169 containing_relation = create(:relation)
170 create(:relation_member, :relation => containing_relation, :member => node)
172 visit node_path(node)
175 assert_link :href => relation_path(containing_relation)
179 test "shows a link to containing relation of a way" do
181 containing_relation = create(:relation)
182 create(:relation_member, :relation => containing_relation, :member => way)
187 assert_link :href => relation_path(containing_relation)
191 test "relation member nodes should be visible on the map when viewing relations" do
192 relation = create(:relation)
194 create(:relation_member, :relation => relation, :member => node)
196 visit relation_path(relation)
198 assert_selector "#map .leaflet-overlay-pane path"
201 test "map should center on a viewed node" do
202 node = create(:node, :lat => 59.55555, :lon => 29.55555)
204 visit node_path(node)
210 share_url = find_by_id("long_input").value
211 assert_match %r{map=\d+/59\.\d+/29\.\d+}, share_url