Use lazy lookups for translations in issues
[rails.git] / test / system / report_diary_comment_test.rb
1 require "application_system_test_case"
2
3 class ReportDiaryCommentTest < ApplicationSystemTestCase
4   def setup
5     create(:language, :code => "en")
6     @diary_entry = create(:diary_entry)
7     @comment = create(:diary_comment, :diary_entry => @diary_entry)
8   end
9
10   def test_no_link_when_not_logged_in
11     visit diary_entry_path(@diary_entry.user.display_name, @diary_entry)
12     assert page.has_content?(@comment.body)
13
14     assert !page.has_content?(I18n.t("diary_entry.diary_comment.report"))
15   end
16
17   def test_it_works
18     sign_in_as(create(:user))
19     visit diary_entry_path(@diary_entry.user.display_name, @diary_entry)
20     assert page.has_content? @diary_entry.title
21
22     click_on I18n.t("diary_entry.diary_comment.report")
23     assert page.has_content? "Report"
24     assert page.has_content? I18n.t("reports.new.disclaimer.intro")
25
26     choose I18n.t("reports.new.categories.diary_comment.spam")
27     fill_in "report_details", :with => "This comment is spam"
28     click_on "Create Report"
29
30     assert page.has_content? "Your report has been registered sucessfully"
31
32     assert_equal 1, Issue.count
33     assert Issue.last.reportable == @comment
34   end
35 end