1
1
use crate :: util:: { RequestHelper , Response , TestApp } ;
2
- use crate :: OkBool ;
3
2
use http:: StatusCode ;
4
3
5
4
pub trait MockEmailHelper : RequestHelper {
6
5
// TODO: I don't like the name of this method or `update_email` on the `MockCookieUser` impl;
7
6
// this is starting to look like a builder might help?
8
7
// I want to explore alternative abstractions in any case.
9
- fn update_email_more_control ( & self , user_id : i32 , email : Option < & str > ) -> Response < OkBool > {
8
+ fn update_email_more_control ( & self , user_id : i32 , email : Option < & str > ) -> Response < ( ) > {
10
9
// When updating your email in crates.io, the request goes to the user route with PUT.
11
10
// Ember sends all the user attributes. We check to make sure the ID in the URL matches
12
11
// the ID of the currently logged in user, then we ignore everything but the email address.
@@ -27,9 +26,11 @@ impl MockEmailHelper for crate::util::MockCookieUser {}
27
26
impl MockEmailHelper for crate :: util:: MockAnonymousUser { }
28
27
29
28
impl crate :: util:: MockCookieUser {
30
- pub fn update_email ( & self , email : & str ) -> OkBool {
29
+ pub fn update_email ( & self , email : & str ) {
31
30
let model = self . as_model ( ) ;
32
- self . update_email_more_control ( model. id , Some ( email) ) . good ( )
31
+ let response = self . update_email_more_control ( model. id , Some ( email) ) ;
32
+ assert_eq ! ( response. status( ) , StatusCode :: OK ) ;
33
+ assert_eq ! ( response. into_json( ) , json!( { "ok" : true } ) ) ;
33
34
}
34
35
}
35
36
0 commit comments