1 require "application_system_test_case"
3 class ElementOldVersionTest < ApplicationSystemTestCase
4 test "shows a node with one version" do
5 node = create(:node, :with_history, :lat => 60, :lon => 30)
7 visit old_node_path(node, 1)
10 assert_css "h2", :text => "Node: #{node.id}"
11 assert_css "h4", :text => "Version #1"
12 assert_text(/Location: 60\.\d+, 30\.\d+/)
14 assert_link "Download XML", :href => api_node_version_path(node, 1)
15 assert_link "View Details", :href => node_path(node)
16 assert_link "View History", :href => node_history_path(node)
20 test "shows a way with one version" do
21 way = create(:way, :with_history)
23 visit old_way_path(way, 1)
26 assert_css "h2", :text => "Way: #{way.id}"
27 assert_css "h4", :text => "Version #1"
29 assert_link "Download XML", :href => api_way_version_path(way, 1)
30 assert_link "View Details", :href => way_path(way)
31 assert_link "View History", :href => way_history_path(way)
35 test "shows a node with two versions" do
36 node = create(:node, :with_history, :version => 2, :lat => 60, :lon => 30)
37 node.old_nodes.find_by(:version => 1).update(:lat => 59, :lon => 29)
39 visit old_node_path(node, 1)
42 assert_css "h2", :text => "Node: #{node.id}"
43 assert_css "h4", :text => "Version #1"
44 assert_text(/Location: 59\.\d+, 29\.\d+/)
46 assert_link "Download XML", :href => api_node_version_path(node, 1)
47 assert_link "View Details", :href => node_path(node)
48 assert_link "View History", :href => node_history_path(node)
52 assert_css "h2", :text => "Node: #{node.id}"
53 assert_css "h4", :text => "Version #2"
54 assert_text(/Location: 60\.\d+, 30\.\d+/)
56 assert_link "Download XML", :href => api_node_version_path(node, 2)
57 assert_link "View Details", :href => node_path(node)
58 assert_link "View History", :href => node_history_path(node)
62 test "shows a way with two versions" do
63 way = create(:way, :with_history, :version => 2)
65 visit old_way_path(way, 1)
68 assert_css "h2", :text => "Way: #{way.id}"
69 assert_css "h4", :text => "Version #1"
71 assert_link "Download XML", :href => api_way_version_path(way, 1)
72 assert_link "View Details", :href => way_path(way)
73 assert_link "View History", :href => way_history_path(way)
77 assert_css "h2", :text => "Way: #{way.id}"
78 assert_css "h4", :text => "Version #2"
80 assert_link "Download XML", :href => api_way_version_path(way, 2)
81 assert_link "View Details", :href => way_path(way)
82 assert_link "View History", :href => way_history_path(way)
86 test "show a redacted node version" do
87 node = create_redacted_node
89 visit old_node_path(node, 1)
92 assert_css "h2", :text => "Node: #{node.id}"
93 assert_text "Version 1 of this node cannot be shown"
94 assert_no_text "Location"
95 assert_no_text "TOP SECRET"
97 assert_no_link "Download XML"
98 assert_no_link "View Redacted Data"
99 assert_link "View Details", :href => node_path(node)
100 assert_link "View History", :href => node_history_path(node)
104 test "show a redacted way version" do
105 way = create_redacted_way
107 visit old_way_path(way, 1)
110 assert_css "h2", :text => "Way: #{way.id}"
111 assert_text "Version 1 of this way cannot be shown"
112 assert_no_text "Location"
113 assert_no_text "TOP SECRET"
115 assert_no_link "Download XML"
116 assert_no_link "View Redacted Data"
117 assert_link "View Details", :href => way_path(way)
118 assert_link "View History", :href => way_history_path(way)
122 test "show a redacted node version to a regular user" do
123 node = create_redacted_node
125 sign_in_as(create(:user))
126 visit old_node_path(node, 1)
129 assert_css "h2", :text => "Node: #{node.id}"
130 assert_text "Version 1 of this node cannot be shown"
131 assert_no_text "Location"
132 assert_no_text "TOP SECRET"
134 assert_no_link "Download XML"
135 assert_no_link "View Redacted Data"
136 assert_link "View Details", :href => node_path(node)
137 assert_link "View History", :href => node_history_path(node)
141 test "show a redacted way version to a regular user" do
142 way = create_redacted_way
144 sign_in_as(create(:user))
145 visit old_way_path(way, 1)
148 assert_css "h2", :text => "Way: #{way.id}"
149 assert_text "Version 1 of this way cannot be shown"
150 assert_no_text "Location"
151 assert_no_text "TOP SECRET"
153 assert_no_link "Download XML"
154 assert_no_link "View Redacted Data"
155 assert_link "View Details", :href => way_path(way)
156 assert_link "View History", :href => way_history_path(way)
160 test "show a redacted node version to a moderator" do
161 node = create_redacted_node
163 sign_in_as(create(:moderator_user))
164 visit old_node_path(node, 1)
167 assert_css "h2", :text => "Node: #{node.id}"
168 assert_text "Version 1 of this node cannot be shown"
169 assert_no_text "Location"
170 assert_no_text "TOP SECRET"
172 assert_no_link "Download XML"
173 assert_link "View Redacted Data"
174 assert_no_link "View Redaction Message"
175 assert_link "View Details", :href => node_path(node)
176 assert_link "View History", :href => node_history_path(node)
178 click_on "View Redacted Data"
180 assert_css "h2", :text => "Node: #{node.id}"
181 assert_css "h4", :text => "Redacted Version #1"
182 assert_text(/Location: 59\.\d+, 29\.\d+/)
183 assert_text "TOP SECRET"
185 assert_no_link "Download XML"
186 assert_no_link "View Redacted Data"
187 assert_link "View Redaction Message"
188 assert_link "View Details", :href => node_path(node)
189 assert_link "View History", :href => node_history_path(node)
191 click_on "View Redaction Message"
193 assert_text "Version 1 of this node cannot be shown"
197 test "show a redacted way version to a moderator" do
198 way = create_redacted_way
200 sign_in_as(create(:moderator_user))
201 visit old_way_path(way, 1)
204 assert_css "h2", :text => "Way: #{way.id}"
205 assert_text "Version 1 of this way cannot be shown"
206 assert_no_text "Location"
207 assert_no_text "TOP SECRET"
209 assert_no_link "Download XML"
210 assert_link "View Redacted Data"
211 assert_no_link "View Redaction Message"
212 assert_link "View Details", :href => way_path(way)
213 assert_link "View History", :href => way_history_path(way)
215 click_on "View Redacted Data"
217 assert_css "h2", :text => "Way: #{way.id}"
218 assert_css "h4", :text => "Redacted Version #1"
219 assert_text "TOP SECRET"
221 assert_no_link "Download XML"
222 assert_no_link "View Redacted Data"
223 assert_link "View Redaction Message"
224 assert_link "View Details", :href => way_path(way)
225 assert_link "View History", :href => way_history_path(way)
227 click_on "View Redaction Message"
229 assert_text "Version 1 of this way cannot be shown"
235 def create_redacted_node
236 create(:node, :with_history, :version => 2, :lat => 60, :lon => 30) do |node|
237 node_v1 = node.old_nodes.find_by(:version => 1)
238 node_v1.update(:lat => 59, :lon => 29)
239 create(:old_node_tag, :old_node => node_v1, :k => "name", :v => "TOP SECRET")
240 node_v1.redact!(create(:redaction))
244 def create_redacted_way
245 create(:way, :with_history, :version => 2) do |way|
246 way_v1 = way.old_ways.find_by(:version => 1)
247 create(:old_way_tag, :old_way => way_v1, :k => "name", :v => "TOP SECRET")
248 way_v1.redact!(create(:redaction))