mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-11-03 20:36:07 +01:00 
			
		
		
		
	Always store primary email address into email_address table and also the state (#15956)
* Always store primary email address into email_address table and also the state * Add lower_email to not convert email to lower as what's added * Fix fixture * Fix tests * Use BeforeInsert to save lower email * Fix v180 migration * fix tests * Fix test * Remove wrong submited codes * Fix test * Fix test * Fix test * Add test for v181 migration * remove change user's email to lower * Revert change on user's email column * Fix lower email * Fix test * Fix test
This commit is contained in:
		@@ -33,7 +33,7 @@ func TestAPIListEmails(t *testing.T) {
 | 
			
		||||
			Primary:  true,
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			Email:    "user21@example.com",
 | 
			
		||||
			Email:    "user2-2@example.com",
 | 
			
		||||
			Verified: false,
 | 
			
		||||
			Primary:  false,
 | 
			
		||||
		},
 | 
			
		||||
@@ -55,7 +55,7 @@ func TestAPIAddEmail(t *testing.T) {
 | 
			
		||||
	session.MakeRequest(t, req, http.StatusUnprocessableEntity)
 | 
			
		||||
 | 
			
		||||
	opts = api.CreateEmailOption{
 | 
			
		||||
		Emails: []string{"user22@example.com"},
 | 
			
		||||
		Emails: []string{"user2-3@example.com"},
 | 
			
		||||
	}
 | 
			
		||||
	req = NewRequestWithJSON(t, "POST", "/api/v1/user/emails?token="+token, &opts)
 | 
			
		||||
	resp := session.MakeRequest(t, req, http.StatusCreated)
 | 
			
		||||
@@ -64,7 +64,7 @@ func TestAPIAddEmail(t *testing.T) {
 | 
			
		||||
	DecodeJSON(t, resp, &emails)
 | 
			
		||||
	assert.EqualValues(t, []*api.Email{
 | 
			
		||||
		{
 | 
			
		||||
			Email:    "user22@example.com",
 | 
			
		||||
			Email:    "user2-3@example.com",
 | 
			
		||||
			Verified: true,
 | 
			
		||||
			Primary:  false,
 | 
			
		||||
		},
 | 
			
		||||
@@ -79,13 +79,13 @@ func TestAPIDeleteEmail(t *testing.T) {
 | 
			
		||||
	token := getTokenForLoggedInUser(t, session)
 | 
			
		||||
 | 
			
		||||
	opts := api.DeleteEmailOption{
 | 
			
		||||
		Emails: []string{"user22@example.com"},
 | 
			
		||||
		Emails: []string{"user2-3@example.com"},
 | 
			
		||||
	}
 | 
			
		||||
	req := NewRequestWithJSON(t, "DELETE", "/api/v1/user/emails?token="+token, &opts)
 | 
			
		||||
	session.MakeRequest(t, req, http.StatusNotFound)
 | 
			
		||||
 | 
			
		||||
	opts = api.DeleteEmailOption{
 | 
			
		||||
		Emails: []string{"user21@example.com"},
 | 
			
		||||
		Emails: []string{"user2-2@example.com"},
 | 
			
		||||
	}
 | 
			
		||||
	req = NewRequestWithJSON(t, "DELETE", "/api/v1/user/emails?token="+token, &opts)
 | 
			
		||||
	session.MakeRequest(t, req, http.StatusNoContent)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user