]> git.openstreetmap.org Git - rails.git/blob - test/system/diary_entry_test.rb
Bump eslint from 8.31.0 to 8.32.0
[rails.git] / test / system / diary_entry_test.rb
1 require "application_system_test_case"
2
3 class DiaryEntrySystemTest < ApplicationSystemTestCase
4   def setup
5     create(:language, :code => "en")
6     @diary_entry = create(:diary_entry)
7   end
8
9   test "reply to diary entry should prefill the message subject" do
10     sign_in_as(create(:user))
11     visit diary_entries_path
12
13     click_on "Send a message to the author"
14
15     assert_content "Send a new message"
16     assert_equal "Re: #{@diary_entry.title}", page.find_field("Subject").value
17   end
18
19   test "deleted diary entries should be hidden for regular users" do
20     @deleted_entry = create(:diary_entry, :visible => false)
21
22     sign_in_as(create(:user))
23     visit diary_entries_path
24
25     assert_no_content @deleted_entry.title
26   end
27
28   test "deleted diary entries should be shown to administrators for review" do
29     @deleted_entry = create(:diary_entry, :visible => false)
30
31     sign_in_as(create(:administrator_user))
32     visit diary_entries_path
33
34     assert_content @deleted_entry.title
35   end
36
37   test "deleted diary entries should not be shown to admins when the user is also deleted" do
38     @deleted_user = create(:user, :deleted)
39     @deleted_entry = create(:diary_entry, :visible => false, :user => @deleted_user)
40
41     sign_in_as(create(:administrator_user))
42     visit diary_entries_path
43
44     assert_no_content @deleted_entry.title
45   end
46
47   test "deleted diary comments should be hidden for regular users" do
48     @deleted_comment = create(:diary_comment, :diary_entry => @diary_entry, :visible => false)
49
50     sign_in_as(create(:user))
51     visit diary_entry_path(@diary_entry.user, @diary_entry)
52
53     assert_no_content @deleted_comment.body
54   end
55
56   test "deleted diary comments should be shown to administrators" do
57     @deleted_comment = create(:diary_comment, :diary_entry => @diary_entry, :visible => false)
58
59     sign_in_as(create(:administrator_user))
60     visit diary_entry_path(@diary_entry.user, @diary_entry)
61
62     assert_content @deleted_comment.body
63   end
64 end