]> git.openstreetmap.org Git - rails.git/blob - test/system/report_diary_entry_test.rb
9d232f8d465f2797a8a5917c603ec7248dc22251
[rails.git] / test / system / report_diary_entry_test.rb
1 require "application_system_test_case"
2
3 class ReportDiaryEntryTest < ApplicationSystemTestCase
4   def setup
5     create(:language, :code => "en")
6     @diary_entry = create(:diary_entry)
7   end
8
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)
12
13     assert_not page.has_content?(I18n.t("diary_entries.diary_entry.report"))
14   end
15
16   def test_it_works
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
20
21     click_on I18n.t("diary_entries.diary_entry.report")
22     assert page.has_content? "Report"
23     assert page.has_content? I18n.t("reports.new.disclaimer.intro")
24
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"
29     end
30
31     assert page.has_content? "Your report has been registered sucessfully"
32
33     assert_equal @diary_entry, Issue.last.reportable
34     assert_equal "administrator", Issue.last.assigned_role
35   end
36
37   def test_it_reopens_issue
38     issue = create(:issue, :reportable => @diary_entry)
39     issue.resolve!
40
41     sign_in_as(create(:user))
42     visit diary_entry_path(@diary_entry.user.display_name, @diary_entry)
43     assert page.has_content? @diary_entry.title
44
45     click_on I18n.t("diary_entries.diary_entry.report")
46     assert page.has_content? "Report"
47     assert page.has_content? I18n.t("reports.new.disclaimer.intro")
48
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"
53     end
54
55     issue.reload
56     assert_not issue.resolved?
57     assert issue.open?
58   end
59
60   def test_missing_report_params
61     sign_in_as(create(:user))
62     visit new_report_path
63     assert page.has_content? I18n.t("reports.new.missing_params")
64   end
65 end