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