mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2026-01-20 10:31:12 +00:00
Use open session in view and populate model attrs
Open session in view was switched off accidentally a while ago. Also the mapping changes recently meant that the changes to @Valid model attributes were not being propagated correctly. Fixes #946 and #947
This commit is contained in:
parent
e870b186fb
commit
d381fb658c
5 changed files with 21 additions and 3 deletions
|
|
@ -173,10 +173,16 @@ class OwnerControllerTests {
|
|||
.andExpect(view().name("redirect:/owners/{ownerId}"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testProcessUpdateOwnerFormUnchangedSuccess() throws Exception {
|
||||
mockMvc.perform(post("/owners/{ownerId}/edit", TEST_OWNER_ID)).andExpect(status().is3xxRedirection())
|
||||
.andExpect(view().name("redirect:/owners/{ownerId}"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testProcessUpdateOwnerFormHasErrors() throws Exception {
|
||||
mockMvc.perform(post("/owners/{ownerId}/edit", TEST_OWNER_ID).param("firstName", "Joe")
|
||||
.param("lastName", "Bloggs").param("city", "London")).andExpect(status().isOk())
|
||||
.param("lastName", "Bloggs").param("address", "").param("telephone", "")).andExpect(status().isOk())
|
||||
.andExpect(model().attributeHasErrors("owner"))
|
||||
.andExpect(model().attributeHasFieldErrors("owner", "address"))
|
||||
.andExpect(model().attributeHasFieldErrors("owner", "telephone"))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue