File tree Expand file tree Collapse file tree 2 files changed +10
-6
lines changed
Expand file tree Collapse file tree 2 files changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -27,6 +27,15 @@ pub struct NewEmail<'a> {
2727}
2828
2929impl NewEmail < ' _ > {
30+ pub async fn insert ( & self , conn : & mut AsyncPgConnection ) -> QueryResult < ( ) > {
31+ diesel:: insert_into ( emails:: table)
32+ . values ( self )
33+ . execute ( conn)
34+ . await ?;
35+
36+ Ok ( ( ) )
37+ }
38+
3039 /// Inserts the email into the database and returns the confirmation token,
3140 /// or does nothing if it already exists and returns `None`.
3241 pub async fn insert_if_missing (
Original file line number Diff line number Diff line change @@ -120,7 +120,6 @@ impl TestApp {
120120 ///
121121 /// This method updates the database directly
122122 pub async fn db_new_user ( & self , username : & str ) -> MockCookieUser {
123- use crate :: schema:: emails;
124123 use diesel_async:: RunQueryDsl ;
125124
126125 let mut conn = self . db_conn ( ) . await ;
@@ -139,11 +138,7 @@ impl TestApp {
139138 verified : true ,
140139 } ;
141140
142- diesel:: insert_into ( emails:: table)
143- . values ( new_email)
144- . execute ( & mut conn)
145- . await
146- . unwrap ( ) ;
141+ new_email. insert ( & mut conn) . await . unwrap ( ) ;
147142
148143 MockCookieUser {
149144 app : self . clone ( ) ,
You can’t perform that action at this time.
0 commit comments