]> git.openstreetmap.org Git - rails.git/blob - test/controllers/old_relations_controller_test.rb
Don't link to xml download from redacted element versions
[rails.git] / test / controllers / old_relations_controller_test.rb
1 require "test_helper"
2
3 class OldRelationsControllerTest < ActionDispatch::IntegrationTest
4   def test_routes
5     assert_routing(
6       { :path => "/relation/1/history/2", :method => :get },
7       { :controller => "old_relations", :action => "show", :id => "1", :version => "2" }
8     )
9   end
10
11   def test_visible
12     relation = create(:relation, :with_history)
13     get old_relation_path(relation, 1)
14     assert_response :success
15     assert_template "old_relations/show"
16     assert_template :layout => "map"
17     assert_select "h4", /^Version/ do
18       assert_select "a[href='#{old_relation_path relation, 1}']", :count => 0
19     end
20     assert_select "a[href='#{relation_version_path relation, 1}']", :count => 1
21   end
22
23   def test_visible_with_members
24     relation = create(:relation, :with_history)
25     create(:old_relation_member, :old_relation => relation.old_relations.first)
26     get old_relation_path(relation, 1)
27     assert_response :success
28     assert_template "old_relations/show"
29     assert_template :layout => "map"
30   end
31
32   def test_redacted
33     relation = create(:relation, :with_history, :deleted, :version => 2)
34     relation_v1 = relation.old_relations.find_by(:version => 1)
35     relation_v1.redact!(create(:redaction))
36     get old_relation_path(relation, 1)
37     assert_response :success
38     assert_template "old_relations/show"
39     assert_template :layout => "map"
40     assert_select "a[href='#{old_relation_path relation, 1}']", :count => 0
41     assert_select "a[href='#{relation_version_path relation, 1}']", :count => 0
42   end
43
44   def test_not_found
45     get old_relation_path(0, 0)
46     assert_response :not_found
47     assert_template "old_relations/not_found"
48     assert_template :layout => "map"
49     assert_select "#sidebar_content", /relation #0 version 0 could not be found/
50   end
51 end