From 1f7c9e6c479da315381ba3469b271f9889836b33 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Fri, 8 Oct 2021 12:33:20 +0300 Subject: Add message editing and updating interval * 3 days for message deletion * 15 minutes for editing --- src/test/java/com/juick/server/tests/ServerTests.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/test/java/com/juick/server/tests') diff --git a/src/test/java/com/juick/server/tests/ServerTests.java b/src/test/java/com/juick/server/tests/ServerTests.java index d19c76cb..faee1f53 100644 --- a/src/test/java/com/juick/server/tests/ServerTests.java +++ b/src/test/java/com/juick/server/tests/ServerTests.java @@ -1306,7 +1306,17 @@ public class ServerTests { .getNewMessage().get(); assertThat(editedComment.getText(), is("HEY, JOE")); assertThat(editedComment.getUpdatedAt(), greaterThan(editedComment.getCreated())); - messagesService.deleteMessage(ugnich.getUid(), original.getMid()); + jdbcTemplate.update("UPDATE replies SET updated_at='1990-05-05 00:00:00' WHERE message_id=? AND reply_id=?", editedComment.getMid(), editedComment.getRid()); + result = mockMvc + .perform(post("/api/update").with(httpBasic(freefdName, freefdPassword)) + .param("mid", String.valueOf(comment.getNewMessage().get().getMid())) + .param("rid", String.valueOf(comment.getNewMessage().get().getRid())).param("body", "HEY, JOE AGAIN")) + .andExpect(status().isBadRequest()).andReturn(); + jdbcTemplate.update("UPDATE messages_txt SET updated_at='1990-05-05 00:00:00' WHERE message_id=?", original.getMid()); + assertThat(messagesService.deleteMessage(ugnich.getUid(), original.getMid()), is(false)); + jdbcTemplate.update("UPDATE messages_txt SET updated_at=? WHERE message_id=?", Instant.now(), original.getMid()); + assertThat(messagesService.deleteMessage(ugnich.getUid(), original.getMid()), is(true)); + } @Test -- cgit v1.2.3