1 require "application_system_test_case"
3 class AccountDeletionTest < ApplicationSystemTestCase
5 @user = create(:user, :display_name => "test user")
9 test "the status is deleted and the personal data removed" do
10 visit edit_account_path
12 click_on "Delete Account..."
14 click_on "Delete Account"
17 assert_current_path root_path
19 assert_equal "deleted", @user.status
20 assert_equal "user_#{@user.id}", @user.display_name
23 test "the user is signed out after deletion" do
24 visit edit_account_path
26 click_on "Delete Account..."
28 click_on "Delete Account"
31 assert_content "Log In"
34 test "the user is shown a confirmation flash message" do
35 visit edit_account_path
37 click_on "Delete Account..."
39 click_on "Delete Account"
42 assert_content "Account Deleted"
45 test "can delete with any delay setting value if the user has no changesets" do
46 with_user_account_deletion_delay(10000) do
48 visit edit_account_path
50 click_on "Delete Account..."
52 assert_no_content "cannot currently be deleted"
57 test "can delete with delay disabled" do
58 with_user_account_deletion_delay(nil) do
59 create(:changeset, :user => @user)
62 visit edit_account_path
64 click_on "Delete Account..."
66 assert_no_content "cannot currently be deleted"
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)
76 visit edit_account_path
78 click_on "Delete Account..."
80 assert_no_content "cannot currently be deleted"
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)
90 visit edit_account_path
92 click_on "Delete Account..."
94 assert_content "cannot currently be deleted"
95 assert_content "in about 1 hour"