1 require "application_system_test_case"
3 class DiaryEntrySystemTest < ApplicationSystemTestCase
5 create(:language, :code => "en")
6 @diary_entry = create(:diary_entry)
9 test "reply to diary entry should prefill the message subject" do
10 sign_in_as(create(:user))
11 visit diary_entries_path
13 click_on "Send a message to the author"
15 assert page.has_content? "Send a new message"
16 assert_equal "Re: #{@diary_entry.title}", page.find_field("Subject").value
19 test "deleted diary entries should be hidden for regular users" do
20 @deleted_entry = create(:diary_entry, :visible => false)
22 sign_in_as(create(:user))
23 visit diary_entries_path
25 assert_not page.has_content? @deleted_entry.title
28 test "deleted diary entries should be shown to administrators for review" do
29 @deleted_entry = create(:diary_entry, :visible => false)
31 sign_in_as(create(:administrator_user))
32 visit diary_entries_path
34 assert page.has_content? @deleted_entry.title
37 test "deleted diary entries should not be shown to admins when the user is also deleted" do
38 @deleted_user = create(:user, :status => :deleted)
39 @deleted_entry = create(:diary_entry, :visible => false, :user => @deleted_user)
41 sign_in_as(create(:administrator_user))
42 visit diary_entries_path
44 assert_not page.has_content? @deleted_entry.title
47 test "deleted diary comments should be hidden for regular users" do
48 @deleted_comment = create(:diary_comment, :diary_entry => @diary_entry, :visible => false)
50 sign_in_as(create(:user))
51 visit diary_entry_path(@diary_entry.user, @diary_entry)
53 assert_not page.has_content? @deleted_comment.body
56 test "deleted diary comments should be shown to administrators" do
57 @deleted_comment = create(:diary_comment, :diary_entry => @diary_entry, :visible => false)
59 sign_in_as(create(:administrator_user))
60 visit diary_entry_path(@diary_entry.user, @diary_entry)
62 assert page.has_content? @deleted_comment.body