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_path way}']", :count => 1
22 assert_select ".secondary-actions a[href='#{way_history_path way}']", :count => 1
25 def test_visible_with_two_versions
26 way = create(:way, :with_history, :version => 2)
27 get old_way_path(way, 1)
28 assert_response :success
29 assert_template "old_ways/show"
30 assert_template :layout => "map"
31 assert_select "h4", /^Version/ do
32 assert_select "a[href='#{old_way_path way, 1}']", :count => 0
34 assert_select ".secondary-actions a[href='#{way_version_path way, 1}']", :count => 1
35 assert_select ".secondary-actions a[href='#{way_path way}']", :count => 1
36 assert_select ".secondary-actions a[href='#{way_history_path way}']", :count => 1
37 assert_select ".secondary-actions a[href='#{old_way_path way, 2}']", :count => 1
39 get old_way_path(way, 2)
40 assert_response :success
41 assert_template "old_ways/show"
42 assert_template :layout => "map"
43 assert_select "h4", /^Version/ do
44 assert_select "a[href='#{old_way_path way, 2}']", :count => 0
46 assert_select ".secondary-actions a[href='#{way_version_path way, 2}']", :count => 1
47 assert_select ".secondary-actions a[href='#{way_path way}']", :count => 1
48 assert_select ".secondary-actions a[href='#{way_history_path way}']", :count => 1
49 assert_select ".secondary-actions a[href='#{old_way_path way, 1}']", :count => 1
52 def test_visible_with_shared_nodes
53 node = create(:node, :with_history)
54 way = create(:way, :with_history)
55 create(:way_node, :way => way, :node => node)
56 create(:old_way_node, :old_way => way.old_ways.first, :node => node)
57 sharing_way = create(:way, :with_history)
58 create(:way_node, :way => sharing_way, :node => node)
59 create(:old_way_node, :old_way => sharing_way.old_ways.first, :node => node)
60 get old_way_path(way, 1)
61 assert_response :success
62 assert_template "old_ways/show"
63 assert_template :layout => "map"
67 way = create(:way, :with_history, :deleted, :version => 2)
68 way_v1 = way.old_ways.find_by(:version => 1)
69 way_v1.redact!(create(:redaction))
70 get old_way_path(way, 1)
71 assert_response :success
72 assert_template "old_ways/show"
73 assert_template :layout => "map"
74 assert_select ".secondary-actions a[href='#{way_path way}']", :count => 1
75 assert_select ".secondary-actions a[href='#{old_way_path way, 1}']", :count => 0
76 assert_select ".secondary-actions a[href='#{way_version_path way, 1}']", :count => 0
80 get old_way_path(0, 0)
81 assert_response :not_found
82 assert_template "old_ways/not_found"
83 assert_template :layout => "map"
84 assert_select "#sidebar_content", /way #0 version 0 could not be found/