]> git.openstreetmap.org Git - rails.git/blob - test/controllers/old_ways_controller_test.rb
f32fdde7756f6c12f092e74141111464ed1ded68
[rails.git] / test / controllers / old_ways_controller_test.rb
1 require "test_helper"
2
3 class OldWaysControllerTest < ActionDispatch::IntegrationTest
4   def test_routes
5     assert_routing(
6       { :path => "/way/1/history/2", :method => :get },
7       { :controller => "old_ways", :action => "show", :id => "1", :version => "2" }
8     )
9   end
10
11   def test_visible
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
19     end
20     assert_select "a[href='#{way_version_path way, 1}']", :count => 1
21   end
22
23   def test_visible_with_shared_nodes
24     node = create(:node, :with_history)
25     way = create(:way, :with_history)
26     create(:way_node, :way => way, :node => node)
27     create(:old_way_node, :old_way => way.old_ways.first, :node => node)
28     sharing_way = create(:way, :with_history)
29     create(:way_node, :way => sharing_way, :node => node)
30     create(:old_way_node, :old_way => sharing_way.old_ways.first, :node => node)
31     get old_way_path(way, 1)
32     assert_response :success
33     assert_template "old_ways/show"
34     assert_template :layout => "map"
35   end
36
37   def test_not_found
38     get old_way_path(0, 0)
39     assert_response :not_found
40     assert_template "old_ways/not_found"
41     assert_template :layout => "map"
42     assert_select "#sidebar_content", /way #0 version 0 could not be found/
43   end
44 end