]> git.openstreetmap.org Git - rails.git/blobdiff - test/system/account_deletion_test.rb
Bump eslint from 8.55.0 to 8.56.0
[rails.git] / test / system / account_deletion_test.rb
index 5a55c5838cb6bda7cb6bb4ee776e3ac53cc7e1b6..e6517dccc38b6bd0c5b17bb3463c5e34111bfdd3 100644 (file)
@@ -9,9 +9,9 @@ class AccountDeletionTest < ApplicationSystemTestCase
   test "the status is deleted and the personal data removed" do
     visit edit_account_path
 
-    click_on "Delete Account..."
+    click_link "Delete Account..."
     accept_confirm do
-      click_on "Delete Account"
+      click_link "Delete Account"
     end
 
     assert_current_path root_path
@@ -23,9 +23,9 @@ class AccountDeletionTest < ApplicationSystemTestCase
   test "the user is signed out after deletion" do
     visit edit_account_path
 
-    click_on "Delete Account..."
+    click_link "Delete Account..."
     accept_confirm do
-      click_on "Delete Account"
+      click_link "Delete Account"
     end
 
     assert_content "Log In"
@@ -34,11 +34,66 @@ class AccountDeletionTest < ApplicationSystemTestCase
   test "the user is shown a confirmation flash message" do
     visit edit_account_path
 
-    click_on "Delete Account..."
+    click_link "Delete Account..."
     accept_confirm do
-      click_on "Delete Account"
+      click_link "Delete Account"
     end
 
     assert_content "Account Deleted"
   end
+
+  test "can delete with any delay setting value if the user has no changesets" do
+    with_user_account_deletion_delay(10000) do
+      travel 1.hour do
+        visit edit_account_path
+
+        click_link "Delete Account..."
+
+        assert_no_content "cannot currently be deleted"
+      end
+    end
+  end
+
+  test "can delete with delay disabled" do
+    with_user_account_deletion_delay(nil) do
+      create(:changeset, :user => @user)
+
+      travel 1.hour do
+        visit edit_account_path
+
+        click_link "Delete Account..."
+
+        assert_no_content "cannot currently be deleted"
+      end
+    end
+  end
+
+  test "can delete when last changeset is old enough" do
+    with_user_account_deletion_delay(10) do
+      create(:changeset, :user => @user, :created_at => Time.now.utc, :closed_at => Time.now.utc + 1.hour)
+
+      travel 12.hours do
+        visit edit_account_path
+
+        click_link "Delete Account..."
+
+        assert_no_content "cannot currently be deleted"
+      end
+    end
+  end
+
+  test "can't delete when last changeset isn't old enough" do
+    with_user_account_deletion_delay(10) do
+      create(:changeset, :user => @user, :created_at => Time.now.utc, :closed_at => Time.now.utc + 1.hour)
+
+      travel 10.hours do
+        visit edit_account_path
+
+        click_link "Delete Account..."
+
+        assert_content "cannot currently be deleted"
+        assert_content "in about 1 hour"
+      end
+    end
+  end
 end