Skip to content

Commit 12c5a55

Browse files
committed
Add a failing test for inviting a user with an older gh_id
Assuming gh_id always increases, if we have multiple users with the same gh_login, the one with the higher id is the most recently valid account we know about
1 parent 2eadd7c commit 12c5a55

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/tests/owners.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,3 +399,25 @@ fn inactive_users_dont_get_invitations() {
399399
let json = invited_user.list_invitations();
400400
assert_eq!(json.crate_owner_invitations.len(), 1);
401401
}
402+
403+
#[test]
404+
fn highest_gh_id_is_most_recent_account_we_know_of() {
405+
let (app, _, owner, owner_token) = TestApp::init().with_token();
406+
let owner = owner.as_model();
407+
408+
// An inactive user with a lower gh_id and an active user with a higher gh_id both exist
409+
let invited_gh_login = "user_bar";
410+
let krate_name = "newer_user_test";
411+
412+
// This user will get a lower gh_id, given how crate::new_user works
413+
app.db_new_user(invited_gh_login);
414+
415+
let invited_user = app.db_new_user(invited_gh_login);
416+
417+
app.db(|conn| { CrateBuilder::new(krate_name, owner.id).expect_build(conn); });
418+
419+
owner_token.add_user_owner(krate_name, invited_user.as_model());
420+
421+
let json = invited_user.list_invitations();
422+
assert_eq!(json.crate_owner_invitations.len(), 1);
423+
}

0 commit comments

Comments
 (0)