Merge branch '2.0.x' into 2.1.x
Closes gh-17078
This commit is contained in:
@@ -63,8 +63,7 @@ public class MessageController {
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
public ModelAndView create(@Valid Message message, BindingResult result,
|
||||
RedirectAttributes redirect) {
|
||||
public ModelAndView create(@Valid Message message, BindingResult result, RedirectAttributes redirect) {
|
||||
if (result.hasErrors()) {
|
||||
ModelAndView mav = new ModelAndView("messages/form");
|
||||
mav.addObject("formErrors", result.getAllErrors());
|
||||
|
||||
@@ -66,15 +66,13 @@ public class MessageControllerWebTests {
|
||||
|
||||
@Test
|
||||
public void testCreate() throws Exception {
|
||||
this.mockMvc.perform(post("/").param("text", "FOO text").param("summary", "FOO"))
|
||||
.andExpect(status().isFound())
|
||||
this.mockMvc.perform(post("/").param("text", "FOO text").param("summary", "FOO")).andExpect(status().isFound())
|
||||
.andExpect(header().string("location", RegexMatcher.matches("/[0-9]+")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateValidation() throws Exception {
|
||||
this.mockMvc.perform(post("/").param("text", "").param("summary", ""))
|
||||
.andExpect(status().isOk())
|
||||
this.mockMvc.perform(post("/").param("text", "").param("summary", "")).andExpect(status().isOk())
|
||||
.andExpect(content().string(containsString("is required")));
|
||||
}
|
||||
|
||||
@@ -98,8 +96,7 @@ public class MessageControllerWebTests {
|
||||
|
||||
@Override
|
||||
public void describeTo(Description description) {
|
||||
description.appendText("a string that matches regex: ")
|
||||
.appendText(this.regex);
|
||||
description.appendText("a string that matches regex: ").appendText(this.regex);
|
||||
}
|
||||
|
||||
public static org.hamcrest.Matcher<java.lang.String> matches(String regex) {
|
||||
|
||||
@@ -68,8 +68,7 @@ public class SampleGroovyTemplateApplicationTests {
|
||||
|
||||
@Test
|
||||
public void testCss() {
|
||||
ResponseEntity<String> entity = this.restTemplate
|
||||
.getForEntity("/css/bootstrap.min.css", String.class);
|
||||
ResponseEntity<String> entity = this.restTemplate.getForEntity("/css/bootstrap.min.css", String.class);
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
assertThat(entity.getBody()).contains("body");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user