]> git.openstreetmap.org Git - rails.git/blob - test/system/report_note_test.rb
Merge remote-tracking branch 'upstream/pull/5744'
[rails.git] / test / system / report_note_test.rb
1 require "application_system_test_case"
2
3 class ReportNoteTest < ApplicationSystemTestCase
4   def test_no_link_when_not_logged_in
5     note = create(:note_with_comments)
6     visit note_path(note)
7     assert_content note.description
8
9     assert_no_content I18n.t("notes.show.report")
10   end
11
12   def test_can_report_anonymous_notes
13     note = create(:note_with_comments)
14     sign_in_as(create(:user))
15     visit note_path(note)
16
17     click_on I18n.t("notes.show.report")
18     assert_content "Report"
19     assert_content I18n.t("reports.new.disclaimer.intro")
20
21     choose I18n.t("reports.new.categories.note.spam_label")
22     fill_in "report_details", :with => "This is spam"
23     assert_difference "Issue.count", 1 do
24       click_on "Create Report"
25     end
26
27     assert_content "Your report has been registered successfully"
28
29     assert_equal note, Issue.last.reportable
30     assert_equal "moderator", Issue.last.assigned_role
31   end
32
33   def test_can_report_notes_with_author
34     user = create(:user)
35     note = create(:note_comment, :author => user, :note => build(:note, :author => user)).note
36     sign_in_as(create(:user))
37     visit note_path(note)
38
39     click_on I18n.t("notes.show.report")
40     assert_content "Report"
41     assert_content I18n.t("reports.new.disclaimer.intro")
42
43     choose I18n.t("reports.new.categories.note.spam_label")
44     fill_in "report_details", :with => "This is spam"
45     assert_difference "Issue.count", 1 do
46       click_on "Create Report"
47     end
48
49     assert_content "Your report has been registered successfully"
50
51     assert_equal note, Issue.last.reportable
52     assert_equal "moderator", Issue.last.assigned_role
53   end
54 end