diff --git a/backend/src/main/java/com/github/binpastes/paste/domain/Paste.java b/backend/src/main/java/com/github/binpastes/paste/domain/Paste.java index 6eb5085..48592db 100644 --- a/backend/src/main/java/com/github/binpastes/paste/domain/Paste.java +++ b/backend/src/main/java/com/github/binpastes/paste/domain/Paste.java @@ -131,7 +131,7 @@ public boolean isErasable(String remoteAddress) { final var createdBySameAuthor = Objects.equals(remoteAddress, this.getRemoteAddress()); if (createdBySameAuthor) { - return this.getDateCreated().isAfter(LocalDateTime.now().minusHours(1)); + return LocalDateTime.now().minusHours(1).isBefore(this.getDateCreated()); } } diff --git a/backend/src/test/java/com/github/binpastes/paste/api/PasteControllerTest.java b/backend/src/test/java/com/github/binpastes/paste/api/PasteControllerTest.java index cc8c8e7..dabed7b 100644 --- a/backend/src/test/java/com/github/binpastes/paste/api/PasteControllerTest.java +++ b/backend/src/test/java/com/github/binpastes/paste/api/PasteControllerTest.java @@ -66,7 +66,7 @@ void searchPastes() { doReturn(Flux.empty()).when(pasteService).findByFullText(anyString()); webClient.get() - .uri("/api/v1/paste/search?term=/{term}", "foobar") + .uri("/api/v1/paste/search?term={term}", "foobar") .exchange() .expectStatus().isOk() .expectHeader().cacheControl(CacheControl.maxAge(60, TimeUnit.SECONDS)) diff --git a/backend/src/test/java/com/github/binpastes/paste/domain/PasteTest.java b/backend/src/test/java/com/github/binpastes/paste/domain/PasteTest.java index 484c5fc..51da4c1 100644 --- a/backend/src/test/java/com/github/binpastes/paste/domain/PasteTest.java +++ b/backend/src/test/java/com/github/binpastes/paste/domain/PasteTest.java @@ -12,6 +12,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Named.named; import static org.junit.jupiter.params.provider.Arguments.arguments; class PasteTest { @@ -40,13 +41,6 @@ void newInstanceDefaults() { assertThat(newPaste.getId()).isNotEmpty(); assertThat(newPaste.getViews()).isZero(); assertThat(newPaste.getLastViewed()).isNull(); - - assertThat(newPaste.getTitle()).isNull(); - assertThat(newPaste.getContent()).isEqualTo("someContent"); - assertThat(newPaste.isPermanent()).isTrue(); - assertThat(newPaste.isEncrypted()).isFalse(); - assertThat(newPaste.isPublic()).isTrue(); - assertThat(newPaste.getRemoteAddress()).isNull(); } @Test @@ -65,7 +59,7 @@ void trackPasteViewCount() { void trackPasteLastViewed() { var newPaste = Paste.newInstance(null, "someContent", null, false, PasteExposure.PUBLIC, null); var now = LocalDateTime.now(); - var yesterday = LocalDateTime.now().minusDays(1); + var yesterday = now.minusDays(1); newPaste.trackView(now); newPaste.trackView(yesterday); @@ -86,21 +80,21 @@ private static Stream pastesToErase() { var unlistedPaste = Paste.newInstance(null, "someContent", null, false, PasteExposure.UNLISTED, "Alice"); var oneTimePaste = Paste.newInstance(null, "someContent", null, false, PasteExposure.ONCE, "Alice"); - var publicPasteRecentlyCreatedByAlice = Paste.newInstance(null, "someContent", null, false, PasteExposure.PUBLIC, "Alice"); - publicPasteRecentlyCreatedByAlice.setDateCreated(LocalDateTime.now().minusMinutes(59)); + var publicPasteRecentlyCreated = Paste.newInstance(null, "someContent", null, false, PasteExposure.PUBLIC, "Alice"); + publicPasteRecentlyCreated.setDateCreated(LocalDateTime.now().minusMinutes(60).plusSeconds(1)); - var publicPasteCreatedSomeTimeAgoByAlice = Paste.newInstance(null, "someContent", null, false, PasteExposure.PUBLIC, "Alice"); - publicPasteCreatedSomeTimeAgoByAlice.setDateCreated(LocalDateTime.now().minusMinutes(60)); + var publicPasteCreatedSomeTimeAgo = Paste.newInstance(null, "someContent", null, false, PasteExposure.PUBLIC, "Alice"); + publicPasteCreatedSomeTimeAgo.setDateCreated(LocalDateTime.now().minusMinutes(60)); return Stream.of( - arguments(unlistedPaste, null, true), - arguments(oneTimePaste, null, true), + arguments(named("unlisted paste", unlistedPaste), null, true), + arguments(named("one-time paste", oneTimePaste), null, true), - arguments(publicPasteRecentlyCreatedByAlice, "Alice", true), - arguments(publicPasteRecentlyCreatedByAlice, "Bob", false), + arguments(named("public paste with recent dateCreated of Alice", publicPasteRecentlyCreated), "Alice", true), + arguments(named("public paste with recent dateCreated of Alice", publicPasteRecentlyCreated), "Bob", false), - arguments(publicPasteCreatedSomeTimeAgoByAlice, "Alice", false), - arguments(publicPasteCreatedSomeTimeAgoByAlice, "Bob", false) + arguments(named("public paste with older dateCreated of Alice", publicPasteCreatedSomeTimeAgo), "Alice", false), + arguments(named("public paste with older dateCreated of Alice", publicPasteCreatedSomeTimeAgo), "Bob", false) ); } } diff --git a/frontend/src/components/Spinner/spinner.css b/frontend/src/components/Spinner/spinner.css index 77f5799..4496df0 100644 --- a/frontend/src/components/Spinner/spinner.css +++ b/frontend/src/components/Spinner/spinner.css @@ -5,7 +5,7 @@ height: 80px; } .lds-ellipsis div { - background: #000; + background: var(--color-text); position: absolute; top: 33px; width: 13px;