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)
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 page.has_content?(I18n.t("issues.index.issues_not_found"))
60 fill_in "search_by_user", :with => "Nonexistant User"
62 assert page.has_content?(I18n.t("issues.index.user_not_found"))
64 # Find Issue against bad_user
66 fill_in "search_by_user", :with => bad_user.display_name
68 assert_not page.has_content?(I18n.t("issues.index.issues_not_found"))
72 issue = create(:issue)
73 sign_in_as(create(:moderator_user))
75 visit issue_path(issue)
77 fill_in :issue_comment_body, :with => "test comment"
79 assert page.has_content?(I18n.t("issue_comments.create.comment_created"))
80 assert page.has_content?("test comment")
83 assert_equal issue.comments.first.body, "test comment"
86 def test_reassign_issue
87 issue = create(:issue)
88 assert_equal "administrator", issue.assigned_role
89 sign_in_as(create(:administrator_user))
91 visit issue_path(issue)
93 fill_in :issue_comment_body, :with => "reassigning to moderators"
98 assert_equal "moderator", issue.assigned_role
101 def test_issue_index_with_multiple_roles
102 user1 = create(:user)
103 user2 = create(:user)
104 issue1 = create(:issue, :reportable => user1, :assigned_role => "administrator")
105 issue2 = create(:issue, :reportable => user2, :assigned_role => "moderator")
107 user = create(:administrator_user)
108 create(:user_role, :user => user, :role => "moderator")
113 assert page.has_link?(I18n.t("issues.index.reports_count", :count => issue1.reports_count), :href => issue_path(issue1))
114 assert page.has_link?(I18n.t("issues.index.reports_count", :count => issue2.reports_count), :href => issue_path(issue2))