mirror of
https://github.com/actix/actix-web.git
synced 2024-12-28 02:50:39 +00:00
Add test for default_resource scope propagation
This commit is contained in:
parent
2f917f3700
commit
f815c1c096
1 changed files with 23 additions and 0 deletions
23
src/scope.rs
23
src/scope.rs
|
@ -1188,4 +1188,27 @@ mod tests {
|
|||
let resp = app.run(req);
|
||||
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 a new issue