1 require "application_system_test_case"
3 class IssuesTest < ApplicationSystemTestCase
6 def test_view_issues_not_logged_in
8 assert_content I18n.t("sessions.new.title")
11 def test_view_issues_normal_user
12 sign_in_as(create(:user))
15 assert_content "Forbidden"
18 def test_view_no_issues
19 sign_in_as(create(:moderator_user))
22 assert_content I18n.t("issues.index.issues_not_found")
26 sign_in_as(create(:moderator_user))
27 issues = create_list(:issue, 3, :assigned_role => "moderator")
30 assert_content issues.first.reported_user.display_name
33 def test_view_issue_with_report
34 sign_in_as(create(:moderator_user))
35 issue = create(:issue, :assigned_role => "moderator")
36 issue.reports << create(:report, :details => "test report text **with kramdown**")
38 visit issue_path(issue)
39 assert_content I18n.t("issues.show.reports", :count => 1)
40 assert_content "test report text with kramdown"
41 assert_selector "strong", :text => "with kramdown"
44 def test_view_issues_with_no_reported_user
45 sign_in_as(create(:moderator_user))
46 anonymous_note = create(:note_with_comments)
47 issue = create(:issue, :reportable => anonymous_note, :assigned_role => "moderator")
50 assert_content reportable_title(anonymous_note)
52 visit issue_path(issue)
53 assert_content reportable_title(anonymous_note)
56 def test_search_issues_by_user
57 good_user = create(:user)
58 bad_user = create(:user)
59 create(:issue, :reportable => bad_user, :reported_user => bad_user, :assigned_role => "administrator")
61 sign_in_as(create(:administrator_user))
63 # No issues against the user
65 fill_in "search_by_user", :with => good_user.display_name
67 assert_no_content I18n.t("issues.index.user_not_found")
68 assert_content I18n.t("issues.index.issues_not_found")
72 fill_in "search_by_user", :with => "Nonexistent User"
74 assert_content I18n.t("issues.index.user_not_found")
75 assert_content I18n.t("issues.index.issues_not_found")
77 # Find Issue against bad_user
79 fill_in "search_by_user", :with => bad_user.display_name
81 assert_no_content I18n.t("issues.index.user_not_found")
82 assert_no_content I18n.t("issues.index.issues_not_found")
86 issue = create(:issue, :assigned_role => "moderator")
87 sign_in_as(create(:moderator_user))
89 visit issue_path(issue)
91 fill_in :issue_comment_body, :with => "test comment"
92 click_on "Add Comment"
93 assert_content I18n.t("issue_comments.create.comment_created")
94 assert_content "test comment"
97 assert_equal("test comment", issue.comments.first.body)
100 def test_reassign_issue
101 issue = create(:issue)
102 assert_equal "administrator", issue.assigned_role
103 sign_in_as(create(:administrator_user))
105 visit issue_path(issue)
107 fill_in :issue_comment_body, :with => "reassigning to moderators"
109 click_on "Add Comment"
112 assert_equal "moderator", issue.assigned_role
115 def test_issue_index_with_multiple_roles
116 user1 = create(:user)
117 user2 = create(:user)
118 issue1 = create(:issue, :reportable => user1, :assigned_role => "administrator")
119 issue2 = create(:issue, :reportable => user2, :assigned_role => "moderator")
121 user = create(:administrator_user)
122 create(:user_role, :user => user, :role => "moderator")
127 assert_link I18n.t("issues.index.reports_count", :count => issue1.reports_count), :href => issue_path(issue1)
128 assert_link I18n.t("issues.index.reports_count", :count => issue2.reports_count), :href => issue_path(issue2)