3 class OldRelationsControllerTest < ActionDispatch::IntegrationTest
6 { :path => "/relation/1/history", :method => :get },
7 { :controller => "old_relations", :action => "index", :id => "1" }
10 { :path => "/relation/1/history/2", :method => :get },
11 { :controller => "old_relations", :action => "show", :id => "1", :version => "2" }
16 relation = create(:relation, :with_history)
17 sidebar_browse_check :relation_history_path, relation.id, "old_elements/index"
21 relation = create(:relation, :with_history)
23 get old_relation_path(relation, 1)
25 assert_response :success
26 assert_template "old_relations/show"
27 assert_template :layout => "map"
30 def test_show_with_members
31 relation = create(:relation, :with_history)
32 create(:old_relation_member, :old_relation => relation.old_relations.first)
34 get old_relation_path(relation, 1)
36 assert_response :success
37 assert_template "old_relations/show"
38 assert_template :layout => "map"
41 def test_show_redacted_to_unauthorized_users
42 relation = create(:relation, :with_history, :version => 2)
43 relation.old_relations.find_by(:version => 1).redact!(create(:redaction))
45 get old_relation_path(relation, 1, :params => { :show_redactions => true })
47 assert_response :redirect
50 def test_show_redacted_to_regular_users
51 relation = create(:relation, :with_history, :version => 2)
52 relation.old_relations.find_by(:version => 1).redact!(create(:redaction))
54 session_for(create(:user))
55 get old_relation_path(relation, 1, :params => { :show_redactions => true })
57 assert_response :redirect
60 def test_show_not_found
61 get old_relation_path(0, 0)
63 assert_response :not_found
64 assert_template "browse/not_found"
65 assert_template :layout => "map"
66 assert_select "#sidebar_content", /relation #0 version 0 could not be found/
70 relation = create(:relation, :with_history)
72 with_settings(:web_timeout => -1) do
73 get old_relation_path(relation, 1)
76 assert_response :error
77 assert_template :layout => "map"
78 assert_dom "h2", "Timeout Error"
79 assert_dom "p", /#{Regexp.quote("the relation with the id #{relation.id}")}/