]> git.openstreetmap.org Git - rails.git/blob - test/system/report_note_test.rb
a18366d011d37e3a73186c3576f47e5a760b50b7
[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 browse_note_path(note)
7     assert page.has_content?(note.comments.first.body)
8
9     assert_not page.has_content?(I18n.t("browse.note.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 browse_note_path(note)
16
17     click_on I18n.t("browse.note.report")
18     assert page.has_content? "Report"
19     assert page.has_content? I18n.t("reports.new.disclaimer.intro")
20
21     choose I18n.t("reports.new.categories.note.spam")
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 page.has_content? "Your report has been registered sucessfully"
28
29     assert_equal note, Issue.last.reportable
30   end
31
32   def test_can_report_notes_with_author
33     note = create(:note_comment, :author => create(:user)).note
34     sign_in_as(create(:user))
35     visit browse_note_path(note)
36
37     click_on I18n.t("browse.note.report")
38     assert page.has_content? "Report"
39     assert page.has_content? I18n.t("reports.new.disclaimer.intro")
40
41     choose I18n.t("reports.new.categories.note.spam")
42     fill_in "report_details", :with => "This is spam"
43     assert_difference "Issue.count", 1 do
44       click_on "Create Report"
45     end
46
47     assert page.has_content? "Your report has been registered sucessfully"
48
49     assert_equal note, Issue.last.reportable
50   end
51 end