]> git.openstreetmap.org Git - rails.git/commitdiff
Rename User#delete to User#destroy
authorAndy Allan <git@gravitystorm.co.uk>
Wed, 22 Dec 2021 11:32:33 +0000 (11:32 +0000)
committerAndy Allan <git@gravitystorm.co.uk>
Wed, 22 Dec 2021 11:32:33 +0000 (11:32 +0000)
"delete" is generally used for immediate SQL deletion without running
any callbacks or other ruby code, whereas "destroy" will trigger callbacks.

Although we don't currently use any callbacks, let's rename this method to
align better with the convention.

app/controllers/users_controller.rb
app/models/user.rb
test/controllers/browse_controller_test.rb
test/models/user_test.rb

index 4f05ece74bc0c451b487de11655e7d847057380d..f7a82c08c6c9df94c00f0b8c6b8be42e19d0c335 100644 (file)
@@ -208,9 +208,9 @@ class UsersController < ApplicationController
   end
 
   ##
-  # delete a user, marking them as deleted and removing personal data
+  # destroy a user, marking them as deleted and removing personal data
   def destroy
-    @user.delete
+    @user.destroy
     redirect_to user_path(:display_name => params[:display_name])
   end
 
index 8b8f31676b6e37870dfb9542ec8bad4229805b26..177a29984c70369042af4ef4053ff7320deed0c4 100644 (file)
@@ -241,8 +241,8 @@ class User < ApplicationRecord
   end
 
   ##
-  # delete a user - leave the account but purge most personal data
-  def delete
+  # destroy a user - leave the account but purge most personal data
+  def destroy
     avatar.purge_later
 
     self.display_name = "user_#{id}"
index 135e49d3f2354c7635516328d9d378a1e957562d..d9f4401bfbf83e61ddd5d6a54c944e715754a816 100644 (file)
@@ -161,7 +161,7 @@ class BrowseControllerTest < ActionDispatch::IntegrationTest
     assert_select "div.note-comments ul li", :count => 2
     assert_select "div.details", /Resolved by #{user.display_name}/
 
-    user.delete
+    user.destroy
 
     reset!
 
index c34b4b81fe310f092b02088ce8b321711ad45865..76f5200912bee738cd54cdec5574bc1db1ff2119 100644 (file)
@@ -256,9 +256,9 @@ class UserTest < ActiveSupport::TestCase
     assert create(:moderator_user).has_role?("moderator")
   end
 
-  def test_delete
+  def test_destroy
     user = create(:user, :with_home_location, :description => "foo")
-    user.delete
+    user.destroy
     assert_equal "user_#{user.id}", user.display_name
     assert user.description.blank?
     assert_nil user.home_lat