@@ -81,20 +81,46 @@ fn show() {
81
81
}
82
82
83
83
#[ test]
84
- fn show_case_insensitive ( ) {
84
+ fn show_latest_user_case_insensitively ( ) {
85
85
let ( _b, app, middle) = :: app ( ) ;
86
86
{
87
87
let conn = t ! ( app. diesel_database. get( ) ) ;
88
88
89
+ // Please do not delete or modify the setup of this test in order to get it to pass.
90
+ // This setup mimics how GitHub works. If someone abandons a GitHub account, the username is
91
+ // available for anyone to take. We need to support having multiple user accounts
92
+ // with the same gh_login in crates.io. `gh_id` is stable across renames, so that field
93
+ // should be used for uniquely identifying GitHub accounts whenever possible. For the
94
+ // crates.io/user/:username pages, the best we can do is show the last crates.io account
95
+ // created with that username.
89
96
t ! (
90
- NewUser :: new
( 1 , "foobar" , Some ( "[email protected] " ) , None , None , "bar" )
91
- . create_or_update( & conn)
97
+ NewUser :: new(
98
+ 1 ,
99
+ "foobar" ,
100
+
101
+ Some ( "I was first then deleted my github account" ) ,
102
+ None ,
103
+ "bar"
104
+ ) . create_or_update( & conn)
105
+ ) ;
106
+ t ! (
107
+ NewUser :: new(
108
+ 2 ,
109
+ "FOOBAR" ,
110
+
111
+ Some ( "I was second, I took the foobar username on github" ) ,
112
+ None ,
113
+ "bar"
114
+ ) . create_or_update( & conn)
92
115
) ;
93
116
}
94
117
let mut req = :: req ( app. clone ( ) , Method :: Get , "api/v1/users/fOObAr" ) ;
95
118
let mut response = ok_resp ! ( middle. call( & mut req) ) ;
96
119
let json: UserShowPublicResponse = :: json ( & mut response) ;
97
- assert_eq ! ( "foobar" , json. user. login) ;
120
+ assert_eq ! (
121
+ "I was second, I took the foobar username on github" ,
122
+ json. user. name. unwrap( )
123
+ ) ;
98
124
}
99
125
100
126
#[ test]
0 commit comments