]> git.openstreetmap.org Git - rails.git/blob - test/system/report_diary_entry_test.rb
Merge branch 'master' into moderation
[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_flag_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 !page.has_content?("\u2690")
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 "\u2690"
22     assert page.has_content? "Report"
23     assert page.has_content? I18n.t("issues.new.disclaimer.intro")
24
25     choose I18n.t("reports.categories.DiaryEntry.spam")
26     fill_in "report_details", :with => "This is advertising"
27     click_on "Create Report"
28
29     assert page.has_content? "Your report has been registered sucessfully"
30   end
31
32   def test_it_reopens_issue
33     issue = create(:issue, :reportable => @diary_entry)
34     issue.resolve!
35
36     sign_in_as(create(:user))
37     visit diary_entry_path(@diary_entry.user.display_name, @diary_entry)
38     assert page.has_content? @diary_entry.title
39
40     click_on "\u2690"
41     assert page.has_content? "Report"
42     assert page.has_content? I18n.t("issues.new.disclaimer.intro")
43
44     choose I18n.t("reports.categories.DiaryEntry.spam")
45     fill_in "report_details", :with => "This is advertising"
46     click_on "Create Report"
47
48     issue.reload
49     assert !issue.resolved?
50     assert issue.open?
51   end
52 end