3 class OldWaysControllerTest < ActionDispatch::IntegrationTest
6 { :path => "/way/1/history", :method => :get },
7 { :controller => "old_ways", :action => "index", :id => "1" }
10 { :path => "/way/1/history/2", :method => :get },
11 { :controller => "old_ways", :action => "show", :id => "1", :version => "2" }
16 way = create(:way, :with_history)
17 sidebar_browse_check :way_history_path, way.id, "old_elements/index"
18 assert_select "h4", /^Version/ do
19 assert_select "a[href='#{old_way_path way, 1}']", :text => "1", :count => 1
23 def test_history_of_redacted
24 way = create(:way, :with_history, :version => 4)
25 way_v1 = way.old_ways.find_by(:version => 1)
26 way_v1.redact!(create(:redaction))
27 way_v3 = way.old_ways.find_by(:version => 3)
28 way_v3.redact!(create(:redaction))
30 get way_history_path(:id => way)
31 assert_response :success
32 assert_template "old_elements/index"
34 # there are 4 revisions of the redacted way, but only 2
35 # should be showing details here.
36 assert_select ".browse-section", 4
37 assert_select ".browse-section.browse-redacted", 2
38 assert_select ".browse-section.browse-way", 2
41 def test_unredacted_history_of_redacted
42 session_for(create(:moderator_user))
43 way = create(:way, :with_history, :version => 4)
44 way_v1 = way.old_ways.find_by(:version => 1)
45 way_v1.redact!(create(:redaction))
46 way_v3 = way.old_ways.find_by(:version => 3)
47 way_v3.redact!(create(:redaction))
49 get way_history_path(:id => way, :params => { :show_redactions => true })
50 assert_response :success
51 assert_template "old_elements/index"
53 assert_select ".browse-section", 4
54 assert_select ".browse-section.browse-redacted", 0
55 assert_select ".browse-section.browse-way", 4
59 way = create(:way, :with_history)
61 get old_way_path(way, 1)
63 assert_response :success
64 assert_template "old_ways/show"
65 assert_template :layout => "map"
68 def test_show_with_shared_nodes
69 node = create(:node, :with_history)
70 way = create(:way, :with_history)
71 create(:way_node, :way => way, :node => node)
72 create(:old_way_node, :old_way => way.old_ways.first, :node => node)
73 sharing_way = create(:way, :with_history)
74 create(:way_node, :way => sharing_way, :node => node)
75 create(:old_way_node, :old_way => sharing_way.old_ways.first, :node => node)
77 get old_way_path(way, 1)
79 assert_response :success
80 assert_template "old_ways/show"
81 assert_template :layout => "map"
84 def test_show_redacted_to_unauthorized_users
85 way = create(:way, :with_history, :version => 2)
86 way.old_ways.find_by(:version => 1).redact!(create(:redaction))
88 get old_way_path(way, 1, :params => { :show_redactions => true })
90 assert_response :redirect
93 def test_show_redacted_to_regular_users
94 way = create(:way, :with_history, :version => 2)
95 way.old_ways.find_by(:version => 1).redact!(create(:redaction))
97 session_for(create(:user))
98 get old_way_path(way, 1, :params => { :show_redactions => true })
100 assert_response :redirect
103 def test_show_not_found
104 get old_way_path(0, 0)
106 assert_response :not_found
107 assert_template "browse/not_found"
108 assert_template :layout => "map"
109 assert_select "#sidebar_content", /way #0 version 0 could not be found/
112 def test_show_timeout
113 way = create(:way, :with_history)
115 with_settings(:web_timeout => -1) do
116 get old_way_path(way, 1)
119 assert_response :error
120 assert_template :layout => "map"
121 assert_dom "h2", "Timeout Error"
122 assert_dom "p", /#{Regexp.quote("the way with the id #{way.id}")}/