-
Notifications
You must be signed in to change notification settings - Fork 645
Drop Email column (merge and deploy the fix for #1888 first!) #1891
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 5 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
521beb7
remove uses of email field on User
mugoh 5ef002d
update tests to match altered fields
mugoh 3544b91
remove email field from dump
mugoh fc01ad4
add requested changes
mugoh 3be2b55
retain original email
mugoh 59f7169
use valid email pattern in test
mugoh 8a8a1d3
fix upstream conflicts
mugoh 2410f44
Remove more temporary code that was needed to remove user.email
carols10cents c7ac5cb
Merge remote-tracking branch 'upstream/master' into drop_email_column
carols10cents File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
CREATE FUNCTION update_categories_crates_cnt() RETURNS trigger AS $$ BEGIN IF (TG_OP = 'INSERT') THEN UPDATE categories SET crates_cnt = crates_cnt + 1 WHERE id = NEW.category_id; return NEW; ELSIF (TG_OP = 'DELETE') THEN UPDATE categories SET crates_cnt = crates_cnt - 1 WHERE id = OLD.category_id; return OLD; END IF; END $$ LANGUAGE plpgsql; CREATE TRIGGER trigger_update_categories_crates_cnt BEFORE INSERT OR DELETE ON crates_categories FOR EACH ROW EXECUTE PROCEDURE update_categories_crates_cnt(); CREATE TRIGGER touch_crate_on_modify_categories AFTER INSERT OR DELETE ON crates_categories FOR EACH ROW EXECUTE PROCEDURE touch_crate(); | ||
CREATE FUNCTION update_categories_crates_cnt() RETURNS trigger AS $$ BEGIN IF (TG_OP = 'INSERT') THEN UPDATE categories SET crates_cnt = crates_cnt + 1 WHERE id = NEW.category_id; return NEW; ELSIF (TG_OP = 'DELETE') THEN UPDATE categories SET crates_cnt = crates_cnt - 1 WHERE id = OLD.category_id; return OLD; END IF; END $$ LANGUAGE plpgsql; CREATE TRIGGER trigger_update_categories_crates_cnt BEFORE INSERT OR DELETE ON crates_categories FOR EACH ROW EXECUTE PROCEDURE update_categories_crates_cnt(); CREATE TRIGGER touch_crate_on_modify_categories AFTER INSERT OR DELETE ON crates_categories FOR EACH ROW EXECUTE PROCEDURE touch_crate(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
-- Not reversible |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ALTER TABLE users DROP COLUMN email CASCADE; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -110,7 +110,7 @@ fn me() { | |
let user = app.db_new_user("foo"); | ||
let json = user.show_me(); | ||
|
||
assert_eq!(json.user.email, user.as_model().email); | ||
assert_eq!(json.user.name, user.as_model().name); | ||
} | ||
|
||
#[test] | ||
|
@@ -141,21 +141,19 @@ fn show_latest_user_case_insensitively() { | |
t!(NewUser::new( | ||
1, | ||
"foobar", | ||
Some("[email protected]"), | ||
Some("I was first then deleted my github account"), | ||
None, | ||
"bar" | ||
) | ||
.create_or_update(conn)); | ||
.create_or_update(None, conn)); | ||
t!(NewUser::new( | ||
2, | ||
"FOOBAR", | ||
Some("[email protected]"), | ||
Some("I was second, I took the foobar username on github"), | ||
None, | ||
"bar" | ||
) | ||
.create_or_update(conn)); | ||
.create_or_update(None, conn)); | ||
}); | ||
|
||
let json: UserShowPublicResponse = anon.get("api/v1/users/fOObAr").good(); | ||
|
@@ -324,7 +322,7 @@ fn updating_existing_user_doesnt_change_api_token() { | |
|
||
let user = app.db(|conn| { | ||
// Reuse gh_id but use new gh_login and gh_access_token | ||
t!(NewUser::new(gh_id, "bar", None, None, None, "bar_token").create_or_update(conn)); | ||
t!(NewUser::new(gh_id, "bar", None, None, "bar_token").create_or_update(None, conn)); | ||
|
||
// Use the original API token to find the now updated user | ||
t!(User::find_by_api_token(conn, token)) | ||
|
@@ -353,7 +351,7 @@ fn github_without_email_does_not_overwrite_email() { | |
// Don't use app.db_new_user because it adds a verified email. | ||
let user_without_github_email = app.db(|conn| { | ||
let u = new_user("arbitrary_username"); | ||
let u = u.create_or_update(conn).unwrap(); | ||
let u = u.create_or_update(None, conn).unwrap(); | ||
MockCookieUser::new(&app, u) | ||
}); | ||
let user_without_github_email_model = user_without_github_email.as_model(); | ||
|
@@ -373,7 +371,7 @@ fn github_without_email_does_not_overwrite_email() { | |
// new_user uses a None email; the rest of the fields are arbitrary | ||
..new_user("arbitrary_username") | ||
}; | ||
let u = u.create_or_update(conn).unwrap(); | ||
let u = u.create_or_update(None, conn).unwrap(); | ||
MockCookieUser::new(&app, u) | ||
}); | ||
|
||
|
@@ -386,9 +384,16 @@ fn github_without_email_does_not_overwrite_email() { | |
*/ | ||
#[test] | ||
fn github_with_email_does_not_overwrite_email() { | ||
use cargo_registry::schema::emails; | ||
|
||
let (app, _, user) = TestApp::init().with_user(); | ||
let model = user.as_model(); | ||
let original_email = &model.email; | ||
let original_email = app.db(|conn| { | ||
Email::belonging_to(model) | ||
.select(emails::email) | ||
.first::<String>(&*conn) | ||
.unwrap() | ||
}); | ||
|
||
let new_github_email = "[email protected]"; | ||
|
||
|
@@ -397,16 +402,15 @@ fn github_with_email_does_not_overwrite_email() { | |
let u = NewUser { | ||
// Use the same github ID to link to the existing account | ||
gh_id: model.gh_id, | ||
email: Some(new_github_email), | ||
// the rest of the fields are arbitrary | ||
..new_user("arbitrary_username") | ||
}; | ||
let u = u.create_or_update(conn).unwrap(); | ||
let u = u.create_or_update(Some(new_github_email), conn).unwrap(); | ||
MockCookieUser::new(&app, u) | ||
}); | ||
|
||
let json = user_with_different_email_in_github.show_me(); | ||
assert_eq!(json.user.email, *original_email); | ||
assert_eq!(json.user.email, Some(original_email)); | ||
} | ||
|
||
/* Given a crates.io user, check that the user's email can be | ||
|
@@ -510,12 +514,13 @@ fn test_confirm_user_email() { | |
|
||
// Simulate logging in via GitHub. Don't use app.db_new_user because it inserts a verified | ||
// email directly into the database and we want to test the verification flow here. | ||
let email = "cow@mammals@milk"; | ||
|
||
let user = app.db(|conn| { | ||
let u = NewUser { | ||
email: Some("[email protected]"), | ||
..new_user("arbitrary_username") | ||
}; | ||
let u = u.create_or_update(conn).unwrap(); | ||
let u = u.create_or_update(Some(email), conn).unwrap(); | ||
MockCookieUser::new(&app, u) | ||
}); | ||
let user_model = user.as_model(); | ||
|
@@ -530,7 +535,7 @@ fn test_confirm_user_email() { | |
user.confirm_email(&email_token); | ||
|
||
let json = user.show_me(); | ||
assert_eq!(json.user.email.unwrap(), "[email protected]"); | ||
assert_eq!(json.user.email.unwrap(), "cow@mammals@milk"); | ||
assert!(json.user.email_verified); | ||
assert!(json.user.email_verification_sent); | ||
} | ||
|
@@ -549,12 +554,12 @@ fn test_existing_user_email() { | |
|
||
// Simulate logging in via GitHub. Don't use app.db_new_user because it inserts a verified | ||
// email directly into the database and we want to test the verification flow here. | ||
let email = "[email protected]"; | ||
let user = app.db(|conn| { | ||
let u = NewUser { | ||
email: Some("[email protected]"), | ||
..new_user("arbitrary_username") | ||
}; | ||
let u = u.create_or_update(conn).unwrap(); | ||
let u = u.create_or_update(Some(email), conn).unwrap(); | ||
update(Email::belonging_to(&u)) | ||
// Users created before we added verification will have | ||
// `NULL` in the `token_generated_at` column. | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -135,9 +135,11 @@ impl TestApp { | |
use diesel::prelude::*; | ||
|
||
let user = self.db(|conn| { | ||
let mut user = crate::new_user(username).create_or_update(conn).unwrap(); | ||
let email = "[email protected]"; | ||
user.email = Some(email.to_string()); | ||
|
||
let user = crate::new_user(username) | ||
.create_or_update(None, conn) | ||
.unwrap(); | ||
diesel::insert_into(emails::table) | ||
.values(( | ||
emails::user_id.eq(user.id), | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious, why is the value different here? Any particular reason, and any reason why it's not a valid email address (two
@
s)?