Merge pull request #9196 from thomasturrell/patch-1

Fix controllers to use Post/Redirect/Get
This commit is contained in:
Loredana Crusoveanu 2020-06-10 21:41:55 +03:00 committed by GitHub
commit 37f48e86fc
2 changed files with 4 additions and 4 deletions

View File

@ -36,7 +36,7 @@ public class UserController {
userRepository.save(user);
model.addAttribute("users", userRepository.findAll());
return "index";
return "redirect:/index";
}
@GetMapping("/edit/{id}")
@ -55,7 +55,7 @@ public class UserController {
userRepository.save(user);
model.addAttribute("users", userRepository.findAll());
return "index";
return "redirect:/index";
}
@GetMapping("/delete/{id}")

View File

@ -41,7 +41,7 @@ public class UserControllerUnitTest {
when(mockedBindingResult.hasErrors()).thenReturn(false);
assertThat(userController.addUser(user, mockedBindingResult, mockedModel)).isEqualTo("index");
assertThat(userController.addUser(user, mockedBindingResult, mockedModel)).isEqualTo("redirect:/index");
}
@Test
@ -64,7 +64,7 @@ public class UserControllerUnitTest {
when(mockedBindingResult.hasErrors()).thenReturn(false);
assertThat(userController.updateUser(1l, user, mockedBindingResult, mockedModel)).isEqualTo("index");
assertThat(userController.updateUser(1l, user, mockedBindingResult, mockedModel)).isEqualTo("redirect:/index");
}
@Test