1 require "application_system_test_case"
3 class ReportDiaryEntryTest < ApplicationSystemTestCase
5 create(:language, :code => "en")
6 @diary_entry = create(:diary_entry)
9 def test_no_link_when_not_logged_in
10 visit diary_entry_path(@diary_entry.user.display_name, @diary_entry)
11 assert_content @diary_entry.title
13 assert_no_content I18n.t("diary_entries.diary_entry.report")
17 sign_in_as(create(:user))
18 visit diary_entry_path(@diary_entry.user.display_name, @diary_entry)
19 assert_content @diary_entry.title
21 click_on I18n.t("diary_entries.diary_entry.report")
22 assert_content "Report"
23 assert_content I18n.t("reports.new.disclaimer.intro")
25 choose I18n.t("reports.new.categories.diary_entry.spam_label")
26 fill_in "report_details", :with => "This is advertising"
27 assert_difference "Issue.count", 1 do
28 click_on "Create Report"
31 assert_content "Your report has been registered successfully"
33 assert_equal @diary_entry, Issue.last.reportable
34 assert_equal "administrator", Issue.last.assigned_role
37 def test_it_reopens_issue
38 issue = create(:issue, :reportable => @diary_entry)
41 sign_in_as(create(:user))
42 visit diary_entry_path(@diary_entry.user.display_name, @diary_entry)
43 assert_content @diary_entry.title
45 click_on I18n.t("diary_entries.diary_entry.report")
46 assert_content "Report"
47 assert_content I18n.t("reports.new.disclaimer.intro")
49 choose I18n.t("reports.new.categories.diary_entry.spam_label")
50 fill_in "report_details", :with => "This is advertising"
51 assert_no_difference "Issue.count" do
52 click_on "Create Report"
56 assert_not_predicate issue, :resolved?
57 assert_predicate issue, :open?
60 def test_missing_report_params
61 sign_in_as(create(:user))
63 assert_content I18n.t("reports.new.missing_params")