1 require "application_system_test_case"
3 class IssuesTest < ApplicationSystemTestCase
6 def test_view_issues_not_logged_in
8 assert page.has_content?(I18n.t("user.login.title"))
11 def test_view_issues_normal_user
12 sign_in_as(create(:user))
15 assert page.has_content?(I18n.t("application.require_moderator_or_admin.not_a_moderator_or_admin"))
18 def test_view_no_issues
19 sign_in_as(create(:moderator_user))
22 assert page.has_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 page.has_content?(issues.first.reported_user.display_name)
33 def test_view_issues_with_no_reported_user
34 sign_in_as(create(:moderator_user))
35 anonymous_note = create(:note_with_comments)
36 issue = create(:issue, :reportable => anonymous_note, :assigned_role => "moderator")
39 assert page.has_content?(reportable_title(anonymous_note))
41 visit issue_path(issue)
42 assert page.has_content?(reportable_title(anonymous_note))
45 def test_search_issues_by_user
46 good_user = create(:user)
47 bad_user = create(:user)
48 create(:issue, :reportable => bad_user, :reported_user => bad_user, :assigned_role => "administrator")
50 sign_in_as(create(:administrator_user))
52 # No issues against the user
54 fill_in "search_by_user", :with => good_user.display_name
56 assert_not page.has_content?(I18n.t("issues.index.user_not_found"))
57 assert page.has_content?(I18n.t("issues.index.issues_not_found"))
61 fill_in "search_by_user", :with => "Nonexistant User"
63 assert page.has_content?(I18n.t("issues.index.user_not_found"))
64 assert page.has_content?(I18n.t("issues.index.issues_not_found"))
66 # Find Issue against bad_user
68 fill_in "search_by_user", :with => bad_user.display_name
70 assert_not page.has_content?(I18n.t("issues.index.user_not_found"))
71 assert_not page.has_content?(I18n.t("issues.index.issues_not_found"))
75 issue = create(:issue)
76 sign_in_as(create(:moderator_user))
78 visit issue_path(issue)
80 fill_in :issue_comment_body, :with => "test comment"
82 assert page.has_content?(I18n.t("issue_comments.create.comment_created"))
83 assert page.has_content?("test comment")
86 assert_equal issue.comments.first.body, "test comment"
89 def test_reassign_issue
90 issue = create(:issue)
91 assert_equal "administrator", issue.assigned_role
92 sign_in_as(create(:administrator_user))
94 visit issue_path(issue)
96 fill_in :issue_comment_body, :with => "reassigning to moderators"
101 assert_equal "moderator", issue.assigned_role
104 def test_issue_index_with_multiple_roles
105 user1 = create(:user)
106 user2 = create(:user)
107 issue1 = create(:issue, :reportable => user1, :assigned_role => "administrator")
108 issue2 = create(:issue, :reportable => user2, :assigned_role => "moderator")
110 user = create(:administrator_user)
111 create(:user_role, :user => user, :role => "moderator")
116 assert page.has_link?(I18n.t("issues.index.reports_count", :count => issue1.reports_count), :href => issue_path(issue1))
117 assert page.has_link?(I18n.t("issues.index.reports_count", :count => issue2.reports_count), :href => issue_path(issue2))