1 # frozen_string_literal: true
 
   3 require "application_system_test_case"
 
   5 class ReportNoteTest < ApplicationSystemTestCase
 
   6   def test_no_link_when_not_logged_in
 
   7     note = create(:note_with_comments)
 
   9     assert_content note.description
 
  11     assert_no_content I18n.t("notes.show.report")
 
  14   def test_can_report_anonymous_notes
 
  15     note = create(:note_with_comments)
 
  16     sign_in_as(create(:user))
 
  19     click_on I18n.t("notes.show.report")
 
  20     assert_content "Report"
 
  21     assert_content I18n.t("reports.new.disclaimer.intro")
 
  23     choose I18n.t("reports.new.categories.note.spam_label")
 
  24     fill_in "report_details", :with => "This is spam"
 
  25     assert_difference "Issue.count", 1 do
 
  26       click_on "Create Report"
 
  29     assert_content "Your report has been registered successfully"
 
  31     assert_equal note, Issue.last.reportable
 
  32     assert_equal "moderator", Issue.last.assigned_role
 
  35   def test_can_report_notes_with_author
 
  37     note = create(:note_comment, :author => user, :note => build(:note, :author => user)).note
 
  38     sign_in_as(create(:user))
 
  41     click_on I18n.t("notes.show.report")
 
  42     assert_content "Report"
 
  43     assert_content I18n.t("reports.new.disclaimer.intro")
 
  45     choose I18n.t("reports.new.categories.note.spam_label")
 
  46     fill_in "report_details", :with => "This is spam"
 
  47     assert_difference "Issue.count", 1 do
 
  48       click_on "Create Report"
 
  51     assert_content "Your report has been registered successfully"
 
  53     assert_equal note, Issue.last.reportable
 
  54     assert_equal "moderator", Issue.last.assigned_role