1 require "application_system_test_case"
3 class ReportUserTest < ApplicationSystemTestCase
4 def test_no_link_when_not_logged_in
5 note = create(:note_with_comments)
6 visit browse_note_path(note)
7 assert_content note.comments.first.body
9 assert_no_content I18n.t("users.show.report")
12 def test_can_report_user
14 sign_in_as(create(:user))
17 click_on I18n.t("users.show.report")
18 assert_content "Report"
19 assert_content I18n.t("reports.new.disclaimer.intro")
21 choose I18n.t("reports.new.categories.user.vandal_label")
22 fill_in "report_details", :with => "This user is a vandal"
23 assert_difference "Issue.count", 1 do
24 click_on "Create Report"
27 assert_content "Your report has been registered successfully"
29 assert_equal user, Issue.last.reportable
30 assert_equal "moderator", Issue.last.assigned_role
33 def test_it_promotes_issues
35 sign_in_as(create(:user))
38 click_on I18n.t("users.show.report")
39 assert_content "Report"
40 assert_content I18n.t("reports.new.disclaimer.intro")
42 choose I18n.t("reports.new.categories.user.vandal_label")
43 fill_in "report_details", :with => "This user is a vandal"
44 assert_difference "Issue.count", 1 do
45 click_on "Create Report"
48 assert_content "Your report has been registered successfully"
50 assert_equal user, Issue.last.reportable
51 assert_equal "moderator", Issue.last.assigned_role
55 click_on I18n.t("users.show.report")
56 assert_content "Report"
57 assert_content I18n.t("reports.new.disclaimer.intro")
59 choose I18n.t("reports.new.categories.user.spam_label")
60 fill_in "report_details", :with => "This user is a spammer"
61 assert_no_difference "Issue.count" do
62 click_on "Create Report"
65 assert_content "Your report has been registered successfully"
67 assert_equal user, Issue.last.reportable
68 assert_equal "administrator", Issue.last.assigned_role