3 class OldWaysControllerTest < ActionDispatch::IntegrationTest
6 { :path => "/way/1/history/2", :method => :get },
7 { :controller => "old_ways", :action => "show", :id => "1", :version => "2" }
11 def test_visible_with_one_version
12 way = create(:way, :with_history)
13 get old_way_path(way, 1)
14 assert_response :success
15 assert_template "old_ways/show"
16 assert_template :layout => "map"
17 assert_select "h4", /^Version/ do
18 assert_select "a[href='#{old_way_path way, 1}']", :count => 0
20 assert_select ".secondary-actions a[href='#{way_version_path way, 1}']", :count => 1
21 assert_select ".secondary-actions a[href='#{way_history_path way}']", :count => 1
24 def test_visible_with_two_versions
25 way = create(:way, :with_history, :version => 2)
26 get old_way_path(way, 1)
27 assert_response :success
28 assert_template "old_ways/show"
29 assert_template :layout => "map"
30 assert_select "h4", /^Version/ do
31 assert_select "a[href='#{old_way_path way, 1}']", :count => 0
33 assert_select ".secondary-actions a[href='#{way_version_path way, 1}']", :count => 1
34 assert_select ".secondary-actions a[href='#{way_history_path way}']", :count => 1
35 assert_select ".secondary-actions a[href='#{old_way_path way, 2}']", :count => 1
37 get old_way_path(way, 2)
38 assert_response :success
39 assert_template "old_ways/show"
40 assert_template :layout => "map"
41 assert_select "h4", /^Version/ do
42 assert_select "a[href='#{old_way_path way, 2}']", :count => 0
44 assert_select ".secondary-actions a[href='#{way_version_path way, 2}']", :count => 1
45 assert_select ".secondary-actions a[href='#{way_history_path way}']", :count => 1
46 assert_select ".secondary-actions a[href='#{old_way_path way, 1}']", :count => 1
49 def test_visible_with_shared_nodes
50 node = create(:node, :with_history)
51 way = create(:way, :with_history)
52 create(:way_node, :way => way, :node => node)
53 create(:old_way_node, :old_way => way.old_ways.first, :node => node)
54 sharing_way = create(:way, :with_history)
55 create(:way_node, :way => sharing_way, :node => node)
56 create(:old_way_node, :old_way => sharing_way.old_ways.first, :node => node)
57 get old_way_path(way, 1)
58 assert_response :success
59 assert_template "old_ways/show"
60 assert_template :layout => "map"
64 way = create(:way, :with_history, :deleted, :version => 2)
65 way_v1 = way.old_ways.find_by(:version => 1)
66 way_v1.redact!(create(:redaction))
67 get old_way_path(way, 1)
68 assert_response :success
69 assert_template "old_ways/show"
70 assert_template :layout => "map"
71 assert_select ".secondary-actions a[href='#{old_way_path way, 1}']", :count => 0
72 assert_select ".secondary-actions a[href='#{way_version_path way, 1}']", :count => 0
76 get old_way_path(0, 0)
77 assert_response :not_found
78 assert_template "old_ways/not_found"
79 assert_template :layout => "map"
80 assert_select "#sidebar_content", /way #0 version 0 could not be found/