]> git.openstreetmap.org Git - rails.git/blob - test/system/account_deletion_test.rb
Add frozen_string_literal comments to ruby files
[rails.git] / test / system / account_deletion_test.rb
1 # frozen_string_literal: true
2
3 require "application_system_test_case"
4
5 class AccountDeletionTest < ApplicationSystemTestCase
6   def setup
7     @user = create(:user, :display_name => "test user")
8     sign_in_as(@user)
9   end
10
11   test "the status is deleted and the personal data removed" do
12     visit account_path
13
14     click_on "Delete Account..."
15     accept_confirm do
16       click_on "Delete Account"
17     end
18
19     assert_current_path root_path
20     @user.reload
21     assert_equal "deleted", @user.status
22     assert_equal "user_#{@user.id}", @user.display_name
23   end
24
25   test "the user is signed out after deletion" do
26     visit account_path
27
28     click_on "Delete Account..."
29     accept_confirm do
30       click_on "Delete Account"
31     end
32
33     assert_content "Log In"
34   end
35
36   test "the user is shown a confirmation flash message" do
37     visit account_path
38
39     click_on "Delete Account..."
40     accept_confirm do
41       click_on "Delete Account"
42     end
43
44     assert_content "Account Deleted"
45   end
46
47   test "can delete with any delay setting value if the user has no changesets" do
48     with_user_account_deletion_delay(10000) do
49       travel 1.hour do
50         visit account_path
51
52         click_on "Delete Account..."
53
54         assert_no_content "cannot currently be deleted"
55       end
56     end
57   end
58
59   test "can delete with delay disabled" do
60     with_user_account_deletion_delay(nil) do
61       create(:changeset, :user => @user)
62
63       travel 1.hour do
64         visit account_path
65
66         click_on "Delete Account..."
67
68         assert_no_content "cannot currently be deleted"
69       end
70     end
71   end
72
73   test "can delete when last changeset is old enough" do
74     with_user_account_deletion_delay(10) do
75       create(:changeset, :user => @user, :created_at => Time.now.utc, :closed_at => Time.now.utc + 1.hour)
76
77       travel 12.hours do
78         visit account_path
79
80         click_on "Delete Account..."
81
82         assert_no_content "cannot currently be deleted"
83       end
84     end
85   end
86
87   test "can't delete when last changeset isn't old enough" do
88     with_user_account_deletion_delay(10) do
89       create(:changeset, :user => @user, :created_at => Time.now.utc, :closed_at => Time.now.utc + 1.hour)
90
91       travel 10.hours do
92         visit account_path
93
94         click_on "Delete Account..."
95
96         assert_content "cannot currently be deleted"
97         assert_content "in about 1 hour"
98       end
99     end
100   end
101 end