]> git.openstreetmap.org Git - rails.git/blob - test/controllers/relations_controller_test.rb
cbaa51c05b8d58d40b2b786f6b92d1c894f8d158
[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, "browse/feature"
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     assert_select ".secondary-actions a[href='#{old_relation_path relation, 1}']", :count => 0
22   end
23
24   def test_show_multiple_versions
25     relation = create(:relation, :with_history, :version => 2)
26     sidebar_browse_check :relation_path, relation.id, "browse/feature"
27     assert_select ".secondary-actions a[href='#{relation_history_path relation}']", :count => 1
28     assert_select ".secondary-actions a[href='#{old_relation_path relation, 1}']", :count => 1
29     assert_select ".secondary-actions a[href='#{old_relation_path relation, 2}']", :count => 1
30   end
31 end