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 page.has_content?(@diary_entry.title)
13 assert_not page.has_content?(I18n.t("diary_entry.diary_entry.report"))
17 sign_in_as(create(:user))
18 visit diary_entry_path(@diary_entry.user.display_name, @diary_entry)
19 assert page.has_content? @diary_entry.title
21 click_on I18n.t("diary_entry.diary_entry.report")
22 assert page.has_content? "Report"
23 assert page.has_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 page.has_content? "Your report has been registered sucessfully"
33 assert_equal @diary_entry, Issue.last.reportable
36 def test_it_reopens_issue
37 issue = create(:issue, :reportable => @diary_entry)
40 sign_in_as(create(:user))
41 visit diary_entry_path(@diary_entry.user.display_name, @diary_entry)
42 assert page.has_content? @diary_entry.title
44 click_on I18n.t("diary_entry.diary_entry.report")
45 assert page.has_content? "Report"
46 assert page.has_content? I18n.t("reports.new.disclaimer.intro")
48 choose I18n.t("reports.new.categories.diary_entry.spam_label")
49 fill_in "report_details", :with => "This is advertising"
50 assert_no_difference "Issue.count" do
51 click_on "Create Report"
55 assert_not issue.resolved?
59 def test_missing_report_params
60 sign_in_as(create(:user))
62 assert page.has_content? I18n.t("reports.new.missing_params")