]> git.openstreetmap.org Git - rails.git/blob - test/controllers/relations_controller_test.rb
Remove checks for absence of links to current element versions
[rails.git] / test / controllers / relations_controller_test.rb
1 require "test_helper"
2
3 class RelationsControllerTest < ActionDispatch::IntegrationTest
4   ##
5   # test all routes which lead to this controller
6   def test_routes
7     assert_routing(
8       { :path => "/relation/1", :method => :get },
9       { :controller => "relations", :action => "show", :id => "1" }
10     )
11   end
12
13   def test_show
14     relation = create(:relation)
15     sidebar_browse_check :relation_path, relation.id, "elements/show"
16     assert_select "h4", /^Version/ do
17       assert_select "a[href='#{old_relation_path relation, 1}']", :text => "1", :count => 1
18     end
19     assert_select ".secondary-actions a[href='#{api_relation_path relation}']", :count => 1
20     assert_select ".secondary-actions a[href='#{relation_history_path relation}']", :count => 1
21   end
22
23   def test_show_multiple_versions
24     relation = create(:relation, :with_history, :version => 2)
25     sidebar_browse_check :relation_path, relation.id, "elements/show"
26     assert_select ".secondary-actions a[href='#{relation_history_path relation}']", :count => 1
27     assert_select ".secondary-actions a[href='#{old_relation_path relation, 1}']", :count => 1
28     assert_select ".secondary-actions a[href='#{old_relation_path relation, 2}']", :count => 1
29   end
30
31   def test_show_relation_member
32     member = create(:relation)
33     relation = create(:relation)
34     create(:relation_member, :relation => relation, :member => member)
35     sidebar_browse_check :relation_path, member.id, "elements/show"
36     assert_select "a[href='#{relation_path relation}']", :count => 1
37   end
38
39   def test_show_timeout
40     relation = create(:relation)
41     with_settings(:web_timeout => -1) do
42       get relation_path(relation)
43     end
44     assert_response :error
45     assert_template :layout => "map"
46     assert_dom "h2", "Timeout Error"
47     assert_dom "p", /#{Regexp.quote("the relation with the id #{relation.id}")}/
48   end
49 end