Skip to content

Commit ad21b51

Browse files
Make owner invites case-insensitive
Co-authored-by: Yuki Okushi <[email protected]>
1 parent 7f86ba8 commit ad21b51

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/models/owner.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ impl Owner {
7171
)?))
7272
} else {
7373
users::table
74-
.filter(users::gh_login.eq(name))
74+
.filter(crate::lower(users::gh_login).eq(name.to_lowercase()))
7575
.first(conn)
7676
.map(Owner::User)
7777
.map_err(|_| cargo_err(&format_args!("could not find user with login `{}`", name)))

src/tests/owners.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ fn new_crate_owner() {
9191
let crate_to_publish = PublishBuilder::new("foo_owner").version("1.0.0");
9292
token.enqueue_publish(crate_to_publish).good();
9393

94-
// Add the second user as an owner
95-
let user2 = app.db_new_user("bar");
96-
token.add_user_owner("foo_owner", "bar");
94+
// Add the second user as an owner (with a different case to make sure that works)
95+
let user2 = app.db_new_user("Bar");
96+
token.add_user_owner("foo_owner", "BAR");
9797

9898
// accept invitation for user to be added as owner
9999
let crate_id = app.db(|conn| Crate::by_name("foo_owner").first::<Crate>(conn).unwrap().id);
@@ -103,7 +103,7 @@ fn new_crate_owner() {
103103
let crates = user2.search_by_user_id(user2.as_model().id);
104104
assert_eq!(crates.crates.len(), 1);
105105

106-
// And upload a new crate as the second user
106+
// And upload a new version as the second user
107107
let crate_to_publish = PublishBuilder::new("foo_owner").version("2.0.0");
108108
user2
109109
.db_new_token("bar_token")

0 commit comments

Comments
 (0)