mirror of
https://github.com/actix/actix-extras.git
synced 2024-11-28 09:42:40 +01:00
Add test for default_resource scope propagation
This commit is contained in:
parent
2f917f3700
commit
f815c1c096
23
src/scope.rs
23
src/scope.rs
@ -1188,4 +1188,27 @@ mod tests {
|
|||||||
let resp = app.run(req);
|
let resp = app.run(req);
|
||||||
assert_eq!(resp.as_msg().status(), StatusCode::NOT_FOUND);
|
assert_eq!(resp.as_msg().status(), StatusCode::NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_default_resource_propagation() {
|
||||||
|
let mut app = App::new()
|
||||||
|
.scope("/app1", |scope| {
|
||||||
|
scope.default_resource(|r| r.f(|_| HttpResponse::BadRequest()))
|
||||||
|
})
|
||||||
|
.scope("/app2", |scope| scope)
|
||||||
|
.default_resource(|r| r.f(|_| HttpResponse::MethodNotAllowed()))
|
||||||
|
.finish();
|
||||||
|
|
||||||
|
let req = TestRequest::with_uri("/non-exist").finish();
|
||||||
|
let resp = app.run(req);
|
||||||
|
assert_eq!(resp.as_msg().status(), StatusCode::METHOD_NOT_ALLOWED);
|
||||||
|
|
||||||
|
let req = TestRequest::with_uri("/app1/non-exist").finish();
|
||||||
|
let resp = app.run(req);
|
||||||
|
assert_eq!(resp.as_msg().status(), StatusCode::BAD_REQUEST);
|
||||||
|
|
||||||
|
let req = TestRequest::with_uri("/app2/non-exist").finish();
|
||||||
|
let resp = app.run(req);
|
||||||
|
assert_eq!(resp.as_msg().status(), StatusCode::METHOD_NOT_ALLOWED);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user