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> {
27
27
}
28
28
29
29
impl 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
+
30
39
/// Inserts the email into the database and returns the confirmation token,
31
40
/// or does nothing if it already exists and returns `None`.
32
41
pub async fn insert_if_missing (
Original file line number Diff line number Diff line change @@ -120,7 +120,6 @@ impl TestApp {
120
120
///
121
121
/// This method updates the database directly
122
122
pub async fn db_new_user ( & self , username : & str ) -> MockCookieUser {
123
- use crate :: schema:: emails;
124
123
use diesel_async:: RunQueryDsl ;
125
124
126
125
let mut conn = self . db_conn ( ) . await ;
@@ -139,11 +138,7 @@ impl TestApp {
139
138
verified : true ,
140
139
} ;
141
140
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 ( ) ;
147
142
148
143
MockCookieUser {
149
144
app : self . clone ( ) ,
You can’t perform that action at this time.
0 commit comments