]> git.openstreetmap.org Git - rails.git/blob - test/system/report_diary_comment_test.rb
Merge pull request #7302 from tomhughes/terms-locale
[rails.git] / test / system / report_diary_comment_test.rb
1 # frozen_string_literal: true
2
3 require "application_system_test_case"
4
5 class ReportDiaryCommentTest < ApplicationSystemTestCase
6   def setup
7     @diary_entry = create(:diary_entry)
8     @comment = create(:diary_comment, :diary_entry => @diary_entry)
9   end
10
11   def test_no_link_when_not_logged_in
12     visit diary_entry_path(@diary_entry.user, @diary_entry)
13     assert_content @comment.body
14
15     assert_no_content I18n.t("diary_entries.diary_comment.report")
16   end
17
18   def test_it_works
19     sign_in_as(create(:user))
20     visit diary_entry_path(@diary_entry.user, @diary_entry)
21     assert_content @diary_entry.title
22
23     click_on I18n.t("diary_entries.diary_comment.report")
24     assert_content "Report"
25     assert_content I18n.t("reports.new.disclaimer.intro")
26
27     choose I18n.t("reports.new.categories.diary_comment.spam_label")
28     fill_in "report_details", :with => "This comment is spam"
29     assert_difference "Issue.count", 1 do
30       click_on "Create Report"
31     end
32
33     assert_content "Your report has been registered successfully"
34
35     assert_equal @comment, Issue.last.reportable
36     assert_equal "administrator", Issue.last.assigned_role
37   end
38 end