3 class IssuesControllerTest < ActionController::TestCase
5 # Access issues list without login
7 assert_response :redirect
8 assert_redirected_to login_path(:referer => issues_path)
10 # Access issues list as normal user
11 session[:user] = create(:user).id
13 assert_response :redirect
14 assert_redirected_to root_path
16 # Access issues list as administrator
17 session[:user] = create(:administrator_user).id
19 assert_response :success
21 # Access issues list as moderator
22 session[:user] = create(:moderator_user).id
24 assert_response :success
28 target_user = create(:user)
29 issue = create(:issue, :reportable => target_user, :reported_user => target_user)
31 # Access issue without login
32 get :show, :params => { :id => issue.id }
33 assert_response :redirect
34 assert_redirected_to login_path(:referer => issue_path(issue))
36 # Access issue as normal user
37 session[:user] = create(:user).id
38 get :show, :params => { :id => issue.id }
39 assert_response :redirect
40 assert_redirected_to root_path
42 # Access issue as administrator
43 session[:user] = create(:administrator_user).id
44 get :show, :params => { :id => issue.id }
45 assert_response :success
47 # Access issue as moderator
48 session[:user] = create(:moderator_user).id
49 get :show, :params => { :id => issue.id }
50 assert_response :success
54 target_user = create(:user)
55 issue = create(:issue, :reportable => target_user, :reported_user => target_user)
57 # Resolve issue without login
58 get :resolve, :params => { :id => issue.id }
59 assert_response :redirect
60 assert_redirected_to login_path(:referer => resolve_issue_path(issue))
62 # Resolve issue as normal user
63 session[:user] = create(:user).id
64 get :resolve, :params => { :id => issue.id }
65 assert_response :redirect
66 assert_redirected_to root_path
68 # Resolve issue as administrator
69 session[:user] = create(:administrator_user).id
70 get :resolve, :params => { :id => issue.id }
71 assert_response :redirect
72 assert_equal true, issue.reload.resolved?
76 # Resolve issue as moderator
77 session[:user] = create(:moderator_user).id
78 get :resolve, :params => { :id => issue.id }
79 assert_response :redirect
80 assert_equal true, issue.reload.resolved?
84 target_user = create(:user)
85 issue = create(:issue, :reportable => target_user, :reported_user => target_user)
87 # Ignore issue without login
88 get :ignore, :params => { :id => issue.id }
89 assert_response :redirect
90 assert_redirected_to login_path(:referer => ignore_issue_path(issue))
92 # Ignore issue as normal user
93 session[:user] = create(:user).id
94 get :ignore, :params => { :id => issue.id }
95 assert_response :redirect
96 assert_redirected_to root_path
98 # Ignore issue as administrator
99 session[:user] = create(:administrator_user).id
100 get :ignore, :params => { :id => issue.id }
101 assert_response :redirect
102 assert_equal true, issue.reload.ignored?
106 # Ignore issue as moderator
107 session[:user] = create(:moderator_user).id
108 get :ignore, :params => { :id => issue.id }
109 assert_response :redirect
110 assert_equal true, issue.reload.ignored?
114 target_user = create(:user)
115 issue = create(:issue, :reportable => target_user, :reported_user => target_user)
119 # Reopen issue without login
120 get :reopen, :params => { :id => issue.id }
121 assert_response :redirect
122 assert_redirected_to login_path(:referer => reopen_issue_path(issue))
124 # Reopen issue as normal user
125 session[:user] = create(:user).id
126 get :reopen, :params => { :id => issue.id }
127 assert_response :redirect
128 assert_redirected_to root_path
130 # Reopen issue as administrator
131 session[:user] = create(:administrator_user).id
132 get :reopen, :params => { :id => issue.id }
133 assert_response :redirect
134 assert_equal true, issue.reload.open?
138 # Reopen issue as moderator
139 session[:user] = create(:moderator_user).id
140 get :reopen, :params => { :id => issue.id }
141 assert_response :redirect
142 assert_equal true, issue.reload.open?