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"
20 def test_index_show_redactions_to_unauthorized
21 relation = create(:relation, :with_history)
23 get relation_history_path(:id => relation, :params => { :show_redactions => true })
25 assert_response :redirect
28 def test_index_show_redactions_to_regular_user
29 relation = create(:relation, :with_history)
31 session_for(create(:user))
32 get relation_history_path(:id => relation, :params => { :show_redactions => true })
34 assert_response :redirect
38 relation = create(:relation, :with_history)
40 get old_relation_path(relation, 1)
42 assert_response :success
43 assert_template "old_relations/show"
44 assert_template :layout => "map"
47 def test_show_with_members
48 relation = create(:relation, :with_history)
49 create(:old_relation_member, :old_relation => relation.old_relations.first)
51 get old_relation_path(relation, 1)
53 assert_response :success
54 assert_template "old_relations/show"
55 assert_template :layout => "map"
58 def test_show_redacted_to_unauthorized_users
59 relation = create(:relation, :with_history, :version => 2)
60 relation.old_relations.find_by(:version => 1).redact!(create(:redaction))
62 get old_relation_path(relation, 1, :params => { :show_redactions => true })
64 assert_response :redirect
67 def test_show_redacted_to_regular_users
68 relation = create(:relation, :with_history, :version => 2)
69 relation.old_relations.find_by(:version => 1).redact!(create(:redaction))
71 session_for(create(:user))
72 get old_relation_path(relation, 1, :params => { :show_redactions => true })
74 assert_response :redirect
77 def test_show_not_found
78 get old_relation_path(0, 0)
80 assert_response :not_found
81 assert_template "browse/not_found"
82 assert_template :layout => "map"
83 assert_select "#sidebar_content", /relation #0 version 0 could not be found/
87 relation = create(:relation, :with_history)
89 with_settings(:web_timeout => -1) do
90 get old_relation_path(relation, 1)
93 assert_response :error
94 assert_template :layout => "map"
95 assert_dom "h2", "Timeout Error"
96 assert_dom "p", /#{Regexp.quote("the relation with the id #{relation.id}")}/