1 require "application_system_test_case"
3 class IssuesTest < ApplicationSystemTestCase
6 def test_view_issues_normal_user
7 sign_in_as(create(:user))
10 assert page.has_content?(I18n.t("application.require_admin.not_an_admin"))
13 def test_view_no_issues
14 sign_in_as(create(:moderator_user))
17 assert page.has_content?(I18n.t(".issues.index.issues_not_found"))
21 sign_in_as(create(:moderator_user))
22 issues = create_list(:issue, 3, :assigned_role => "moderator")
25 assert page.has_content?(issues.first.reported_user.display_name)
28 def test_view_issues_with_no_reported_user
29 sign_in_as(create(:moderator_user))
30 anonymous_note = create(:note_with_comments)
31 issue = create(:issue, :reportable => anonymous_note)
34 assert page.has_content?(reportable_title(anonymous_note))
36 visit issue_path(issue)
37 assert page.has_content?(reportable_title(anonymous_note))
40 def test_search_issues_by_user
41 good_user = create(:user)
42 bad_user = create(:user)
43 create(:issue, :reportable => bad_user, :reported_user => bad_user, :assigned_role => "administrator")
45 sign_in_as(create(:administrator_user))
47 # No issues against the user
49 fill_in "search_by_user", :with => good_user.display_name
51 assert page.has_content?(I18n.t(".issues.index.issues_not_found"))
55 fill_in "search_by_user", :with => "Nonexistant User"
57 assert page.has_content?(I18n.t(".issues.index.user_not_found"))
59 # Find Issue against bad_user
61 fill_in "search_by_user", :with => bad_user.display_name
63 assert !page.has_content?(I18n.t(".issues.index.issues_not_found"))
67 issue = create(:issue)
68 sign_in_as(create(:moderator_user))
70 visit issue_path(issue)
72 fill_in :issue_comment_body, :with => "test comment"
74 assert page.has_content?(I18n.t(".issues.comment.comment_created"))
75 assert page.has_content?("test comment")
78 assert_equal issue.comments.first.body, "test comment"
81 def test_reassign_issue
82 issue = create(:issue)
83 assert_equal "administrator", issue.assigned_role
84 sign_in_as(create(:administrator_user))
86 visit issue_path(issue)
88 fill_in :issue_comment_body, :with => "reassigning to moderators"
93 assert_equal "moderator", issue.assigned_role
96 def test_issue_index_with_multiple_roles
99 issue1 = create(:issue, :reportable => user1, :assigned_role => "administrator")
100 issue2 = create(:issue, :reportable => user2, :assigned_role => "moderator")
102 user = create(:administrator_user)
103 create(:user_role, :user => user, :role => "moderator")
108 assert page.has_link?(I18n.t(".issues.index.reports_count", :count => issue1.reports_count), :href => issue_path(issue1))
109 assert page.has_link?(I18n.t(".issues.index.reports_count", :count => issue2.reports_count), :href => issue_path(issue2))