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"
21 way = create(:way, :with_history)
23 get old_way_path(way, 1)
25 assert_response :success
26 assert_template "old_ways/show"
27 assert_template :layout => "map"
30 def test_show_with_shared_nodes
31 node = create(:node, :with_history)
32 way = create(:way, :with_history)
33 create(:way_node, :way => way, :node => node)
34 create(:old_way_node, :old_way => way.old_ways.first, :node => node)
35 sharing_way = create(:way, :with_history)
36 create(:way_node, :way => sharing_way, :node => node)
37 create(:old_way_node, :old_way => sharing_way.old_ways.first, :node => node)
39 get old_way_path(way, 1)
41 assert_response :success
42 assert_template "old_ways/show"
43 assert_template :layout => "map"
46 def test_show_redacted_to_unauthorized_users
47 way = create(:way, :with_history, :version => 2)
48 way.old_ways.find_by(:version => 1).redact!(create(:redaction))
50 get old_way_path(way, 1, :params => { :show_redactions => true })
52 assert_response :redirect
55 def test_show_redacted_to_regular_users
56 way = create(:way, :with_history, :version => 2)
57 way.old_ways.find_by(:version => 1).redact!(create(:redaction))
59 session_for(create(:user))
60 get old_way_path(way, 1, :params => { :show_redactions => true })
62 assert_response :redirect
65 def test_show_not_found
66 get old_way_path(0, 0)
68 assert_response :not_found
69 assert_template "browse/not_found"
70 assert_template :layout => "map"
71 assert_select "#sidebar_content", /way #0 version 0 could not be found/
75 way = create(:way, :with_history)
77 with_settings(:web_timeout => -1) do
78 get old_way_path(way, 1)
81 assert_response :error
82 assert_template :layout => "map"
83 assert_dom "h2", "Timeout Error"
84 assert_dom "p", /#{Regexp.quote("the way with the id #{way.id}")}/