3 class OldRelationsControllerTest < ActionDispatch::IntegrationTest
6 { :path => "/relation/1/history/2", :method => :get },
7 { :controller => "old_relations", :action => "show", :id => "1", :version => "2" }
11 def test_visible_with_one_version
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
20 assert_select ".secondary-actions a[href='#{relation_version_path relation, 1}']", :count => 1
21 assert_select ".secondary-actions a[href='#{relation_history_path relation}']", :count => 1
24 def test_visible_with_two_versions
25 relation = create(:relation, :with_history, :version => 2)
26 get old_relation_path(relation, 1)
27 assert_response :success
28 assert_template "old_relations/show"
29 assert_template :layout => "map"
30 assert_select "h4", /^Version/ do
31 assert_select "a[href='#{old_relation_path relation, 1}']", :count => 0
33 assert_select ".secondary-actions a[href='#{relation_version_path relation, 1}']", :count => 1
34 assert_select ".secondary-actions a[href='#{relation_history_path relation}']", :count => 1
35 assert_select ".secondary-actions a[href='#{old_relation_path relation, 2}']", :count => 1
37 get old_relation_path(relation, 2)
38 assert_response :success
39 assert_template "old_relations/show"
40 assert_template :layout => "map"
41 assert_select "h4", /^Version/ do
42 assert_select "a[href='#{old_relation_path relation, 2}']", :count => 0
44 assert_select ".secondary-actions a[href='#{relation_version_path relation, 2}']", :count => 1
45 assert_select ".secondary-actions a[href='#{relation_history_path relation}']", :count => 1
46 assert_select ".secondary-actions a[href='#{old_relation_path relation, 1}']", :count => 1
49 def test_visible_with_members
50 relation = create(:relation, :with_history)
51 create(:old_relation_member, :old_relation => relation.old_relations.first)
52 get old_relation_path(relation, 1)
53 assert_response :success
54 assert_template "old_relations/show"
55 assert_template :layout => "map"
59 relation = create(:relation, :with_history, :deleted, :version => 2)
60 relation_v1 = relation.old_relations.find_by(:version => 1)
61 relation_v1.redact!(create(:redaction))
62 get old_relation_path(relation, 1)
63 assert_response :success
64 assert_template "old_relations/show"
65 assert_template :layout => "map"
66 assert_select ".secondary-actions a[href='#{old_relation_path relation, 1}']", :count => 0
67 assert_select ".secondary-actions a[href='#{relation_version_path relation, 1}']", :count => 0
71 get old_relation_path(0, 0)
72 assert_response :not_found
73 assert_template "old_relations/not_found"
74 assert_template :layout => "map"
75 assert_select "#sidebar_content", /relation #0 version 0 could not be found/