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"
20 def test_index_show_redactions_to_unauthorized
21 way = create(:way, :with_history)
23 get way_history_path(:id => way, :params => { :show_redactions => true })
25 assert_response :redirect
28 def test_index_show_redactions_to_regular_user
29 way = create(:way, :with_history)
31 session_for(create(:user))
32 get way_history_path(:id => way, :params => { :show_redactions => true })
34 assert_response :redirect
38 way = create(:way, :with_history)
40 get old_way_path(way, 1)
42 assert_response :success
43 assert_template "old_ways/show"
44 assert_template :layout => "map"
47 def test_show_with_shared_nodes
48 node = create(:node, :with_history)
49 way = create(:way, :with_history)
50 create(:way_node, :way => way, :node => node)
51 create(:old_way_node, :old_way => way.old_ways.first, :node => node)
52 sharing_way = create(:way, :with_history)
53 create(:way_node, :way => sharing_way, :node => node)
54 create(:old_way_node, :old_way => sharing_way.old_ways.first, :node => node)
56 get old_way_path(way, 1)
58 assert_response :success
59 assert_template "old_ways/show"
60 assert_template :layout => "map"
63 def test_show_redacted_to_unauthorized_users
64 way = create(:way, :with_history, :version => 2)
65 way.old_ways.find_by(:version => 1).redact!(create(:redaction))
67 get old_way_path(way, 1, :params => { :show_redactions => true })
69 assert_response :redirect
72 def test_show_redacted_to_regular_users
73 way = create(:way, :with_history, :version => 2)
74 way.old_ways.find_by(:version => 1).redact!(create(:redaction))
76 session_for(create(:user))
77 get old_way_path(way, 1, :params => { :show_redactions => true })
79 assert_response :redirect
82 def test_show_not_found
83 get old_way_path(0, 0)
85 assert_response :not_found
86 assert_template "browse/not_found"
87 assert_template :layout => "map"
88 assert_select "#sidebar_content", /way #0 version 0 could not be found/
92 way = create(:way, :with_history)
94 with_settings(:web_timeout => -1) do
95 get old_way_path(way, 1)
98 assert_response :error
99 assert_template :layout => "map"
100 assert_dom "h2", "Timeout Error"
101 assert_dom "p", /#{Regexp.quote("the way with the id #{way.id}")}/