[MODERATION] Purge issues on user deletion (squash)
(cherry picked from commit4f529d9596) (cherry picked from commitf0e3acadd3)
This commit is contained in:
		
							parent
							
								
									0a0c07d78a
								
							
						
					
					
						commit
						682c4effe6
					
				
					 8 changed files with 134 additions and 22 deletions
				
			
		| 
						 | 
				
			
			@ -338,20 +338,3 @@
 | 
			
		|||
  created_unix: 978307210
 | 
			
		||||
  updated_unix: 978307210
 | 
			
		||||
  is_locked: false
 | 
			
		||||
 | 
			
		||||
-
 | 
			
		||||
  id: 21
 | 
			
		||||
  repo_id: 10
 | 
			
		||||
  index: 2
 | 
			
		||||
  poster_id: 8
 | 
			
		||||
  original_author_id: 0
 | 
			
		||||
  name: issue for pr
 | 
			
		||||
  content: content
 | 
			
		||||
  milestone_id: 0
 | 
			
		||||
  priority: 0
 | 
			
		||||
  is_closed: false
 | 
			
		||||
  is_pull: false
 | 
			
		||||
  num_comments: 0
 | 
			
		||||
  created_unix: 946684830
 | 
			
		||||
  updated_unix: 978307200
 | 
			
		||||
  is_locked: false
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -9,7 +9,7 @@
 | 
			
		|||
  max_index: 2
 | 
			
		||||
-
 | 
			
		||||
  group_id: 10
 | 
			
		||||
  max_index: 2
 | 
			
		||||
  max_index: 1
 | 
			
		||||
-
 | 
			
		||||
  group_id: 32
 | 
			
		||||
  max_index: 2
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -283,7 +283,7 @@
 | 
			
		|||
  num_watches: 0
 | 
			
		||||
  num_stars: 0
 | 
			
		||||
  num_forks: 1
 | 
			
		||||
  num_issues: 1
 | 
			
		||||
  num_issues: 0
 | 
			
		||||
  num_closed_issues: 0
 | 
			
		||||
  num_pulls: 1
 | 
			
		||||
  num_closed_pulls: 0
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,10 +4,12 @@
 | 
			
		|||
package integration
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"net/http"
 | 
			
		||||
	"strconv"
 | 
			
		||||
	"testing"
 | 
			
		||||
 | 
			
		||||
	issues_model "code.gitea.io/gitea/models/issues"
 | 
			
		||||
	"code.gitea.io/gitea/models/unittest"
 | 
			
		||||
	user_model "code.gitea.io/gitea/models/user"
 | 
			
		||||
	"code.gitea.io/gitea/tests"
 | 
			
		||||
| 
						 | 
				
			
			@ -68,17 +70,22 @@ func makeRequest(t *testing.T, formData user_model.User, headerCode int) {
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
func TestAdminDeleteUser(t *testing.T) {
 | 
			
		||||
	defer tests.AddFixtures("tests/integration/fixtures/TestAdminDeleteUser/")()
 | 
			
		||||
	defer tests.PrepareTestEnv(t)()
 | 
			
		||||
 | 
			
		||||
	session := loginUser(t, "user1")
 | 
			
		||||
 | 
			
		||||
	csrf := GetCSRF(t, session, "/admin/users/8/edit")
 | 
			
		||||
	req := NewRequestWithValues(t, "POST", "/admin/users/8/delete", map[string]string{
 | 
			
		||||
	userID := int64(1000)
 | 
			
		||||
 | 
			
		||||
	unittest.AssertExistsAndLoadBean(t, &issues_model.Issue{PosterID: userID})
 | 
			
		||||
 | 
			
		||||
	csrf := GetCSRF(t, session, fmt.Sprintf("/admin/users/%d/edit", userID))
 | 
			
		||||
	req := NewRequestWithValues(t, "POST", fmt.Sprintf("/admin/users/%d/delete", userID), map[string]string{
 | 
			
		||||
		"_csrf": csrf,
 | 
			
		||||
		"purge": "true",
 | 
			
		||||
	})
 | 
			
		||||
	session.MakeRequest(t, req, http.StatusSeeOther)
 | 
			
		||||
 | 
			
		||||
	assertUserDeleted(t, 8, true)
 | 
			
		||||
	assertUserDeleted(t, userID, true)
 | 
			
		||||
	unittest.CheckConsistencyFor(t, &user_model.User{})
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										16
									
								
								tests/integration/fixtures/TestAdminDeleteUser/issue.yml
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								tests/integration/fixtures/TestAdminDeleteUser/issue.yml
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,16 @@
 | 
			
		|||
-
 | 
			
		||||
  id: 1000
 | 
			
		||||
  repo_id: 1000
 | 
			
		||||
  index: 2
 | 
			
		||||
  poster_id: 1000
 | 
			
		||||
  original_author_id: 0
 | 
			
		||||
  name: NAME
 | 
			
		||||
  content: content
 | 
			
		||||
  milestone_id: 0
 | 
			
		||||
  priority: 0
 | 
			
		||||
  is_closed: false
 | 
			
		||||
  is_pull: false
 | 
			
		||||
  num_comments: 0
 | 
			
		||||
  created_unix: 946684830
 | 
			
		||||
  updated_unix: 978307200
 | 
			
		||||
  is_locked: false
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,3 @@
 | 
			
		|||
-
 | 
			
		||||
  group_id: 1000
 | 
			
		||||
  max_index: 2
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,30 @@
 | 
			
		|||
-
 | 
			
		||||
  id: 1000
 | 
			
		||||
  owner_id: 1001
 | 
			
		||||
  owner_name: user1001
 | 
			
		||||
  lower_name: repo1000
 | 
			
		||||
  name: repo1000
 | 
			
		||||
  default_branch: master
 | 
			
		||||
  num_watches: 0
 | 
			
		||||
  num_stars: 0
 | 
			
		||||
  num_forks: 0
 | 
			
		||||
  num_issues: 1
 | 
			
		||||
  num_closed_issues: 0
 | 
			
		||||
  num_pulls: 0
 | 
			
		||||
  num_closed_pulls: 0
 | 
			
		||||
  num_milestones: 0
 | 
			
		||||
  num_closed_milestones: 0
 | 
			
		||||
  num_projects: 0
 | 
			
		||||
  num_closed_projects: 0
 | 
			
		||||
  is_private: false
 | 
			
		||||
  is_empty: false
 | 
			
		||||
  is_archived: false
 | 
			
		||||
  is_mirror: false
 | 
			
		||||
  status: 0
 | 
			
		||||
  is_fork: false
 | 
			
		||||
  fork_id: 0
 | 
			
		||||
  is_template: false
 | 
			
		||||
  template_id: 0
 | 
			
		||||
  size: 0
 | 
			
		||||
  is_fsck_enabled: true
 | 
			
		||||
  close_issues_via_commit_in_any_branch: false
 | 
			
		||||
							
								
								
									
										73
									
								
								tests/integration/fixtures/TestAdminDeleteUser/user.yml
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										73
									
								
								tests/integration/fixtures/TestAdminDeleteUser/user.yml
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,73 @@
 | 
			
		|||
-
 | 
			
		||||
  id: 1000
 | 
			
		||||
  lower_name: user1000
 | 
			
		||||
  name: user1000
 | 
			
		||||
  full_name: User Thousand
 | 
			
		||||
  email: user1000@example.com
 | 
			
		||||
  keep_email_private: false
 | 
			
		||||
  email_notifications_preference: enabled
 | 
			
		||||
  passwd: ZogKvWdyEx:password
 | 
			
		||||
  passwd_hash_algo: dummy
 | 
			
		||||
  must_change_password: false
 | 
			
		||||
  login_source: 0
 | 
			
		||||
  login_name: user1000
 | 
			
		||||
  type: 0
 | 
			
		||||
  salt: ZogKvWdyEx
 | 
			
		||||
  max_repo_creation: -1
 | 
			
		||||
  is_active: true
 | 
			
		||||
  is_admin: false
 | 
			
		||||
  is_restricted: false
 | 
			
		||||
  allow_git_hook: false
 | 
			
		||||
  allow_import_local: false
 | 
			
		||||
  allow_create_organization: true
 | 
			
		||||
  prohibit_login: false
 | 
			
		||||
  avatar: avatar1000
 | 
			
		||||
  avatar_email: user1000@example.com
 | 
			
		||||
  use_custom_avatar: false
 | 
			
		||||
  num_followers: 1
 | 
			
		||||
  num_following: 1
 | 
			
		||||
  num_stars: 0
 | 
			
		||||
  num_repos: 0
 | 
			
		||||
  num_teams: 0
 | 
			
		||||
  num_members: 0
 | 
			
		||||
  visibility: 0
 | 
			
		||||
  repo_admin_change_team_access: false
 | 
			
		||||
  theme: ""
 | 
			
		||||
  keep_activity_private: false
 | 
			
		||||
 | 
			
		||||
-
 | 
			
		||||
  id: 1001
 | 
			
		||||
  lower_name: user1001
 | 
			
		||||
  name: user1001
 | 
			
		||||
  full_name: User 1001
 | 
			
		||||
  email: user1001@example.com
 | 
			
		||||
  keep_email_private: false
 | 
			
		||||
  email_notifications_preference: enabled
 | 
			
		||||
  passwd: ZogKvWdyEx:password
 | 
			
		||||
  passwd_hash_algo: dummy
 | 
			
		||||
  must_change_password: false
 | 
			
		||||
  login_source: 0
 | 
			
		||||
  login_name: user1001
 | 
			
		||||
  type: 0
 | 
			
		||||
  salt: ZogKvWdyEx
 | 
			
		||||
  max_repo_creation: -1
 | 
			
		||||
  is_active: true
 | 
			
		||||
  is_admin: false
 | 
			
		||||
  is_restricted: false
 | 
			
		||||
  allow_git_hook: false
 | 
			
		||||
  allow_import_local: false
 | 
			
		||||
  allow_create_organization: true
 | 
			
		||||
  prohibit_login: false
 | 
			
		||||
  avatar: avatar1001
 | 
			
		||||
  avatar_email: user1001@example.com
 | 
			
		||||
  use_custom_avatar: false
 | 
			
		||||
  num_followers: 0
 | 
			
		||||
  num_following: 0
 | 
			
		||||
  num_stars: 0
 | 
			
		||||
  num_repos: 1
 | 
			
		||||
  num_teams: 0
 | 
			
		||||
  num_members: 0
 | 
			
		||||
  visibility: 0
 | 
			
		||||
  repo_admin_change_team_access: false
 | 
			
		||||
  theme: ""
 | 
			
		||||
  keep_activity_private: false
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue