aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--juick-www/src/main/java/com/juick/www/controllers/AnythingFilter.java4
-rw-r--r--juick-www/src/test/java/com/juick/WebAppTests.java4
2 files changed, 6 insertions, 2 deletions
diff --git a/juick-www/src/main/java/com/juick/www/controllers/AnythingFilter.java b/juick-www/src/main/java/com/juick/www/controllers/AnythingFilter.java
index 52e748f0..2e6da6c3 100644
--- a/juick-www/src/main/java/com/juick/www/controllers/AnythingFilter.java
+++ b/juick-www/src/main/java/com/juick/www/controllers/AnythingFilter.java
@@ -39,7 +39,9 @@ public class AnythingFilter implements Filter {
com.juick.User author = messagesService.getMessageAuthor(messageId);
if (author != null) {
- ((HttpServletResponse)servletResponse).sendRedirect("/" + author.getName() + "/" + anything);
+ HttpServletResponse response = ((HttpServletResponse)servletResponse);
+ response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY);
+ response.setHeader("Location", "/" + author.getName() + "/" + anything);
return;
}
}
diff --git a/juick-www/src/test/java/com/juick/WebAppTests.java b/juick-www/src/test/java/com/juick/WebAppTests.java
index 1041596a..e74b694e 100644
--- a/juick-www/src/test/java/com/juick/WebAppTests.java
+++ b/juick-www/src/test/java/com/juick/WebAppTests.java
@@ -384,7 +384,9 @@ public class WebAppTests {
@Test
public void anythingRedirects() throws Exception {
int mid = messagesService.createMessage(ugnich.getUid(), "yo", null, null);
- mockMvc.perform(get(String.format("/%d", mid))).andExpect(redirectedUrl(String.format("/%s/%d", ugnich.getName(), mid)));
+ mockMvc.perform(get(String.format("/%d", mid)))
+ .andExpect(status().isMovedPermanently())
+ .andExpect(redirectedUrl(String.format("/%s/%d", ugnich.getName(), mid)));
}
@Test
public void appAssociationsTest() throws Exception {