Skip to content

Commit

Permalink
fix: add isModified column
Browse files Browse the repository at this point in the history
  • Loading branch information
aiaiaiai1 committed Nov 28, 2024
1 parent 062e0fc commit a92e033
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 18 deletions.
6 changes: 5 additions & 1 deletion src/main/java/gymmi/photoboard/domain/entity/PhotoFeed.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,21 @@ public class PhotoFeed extends TimeEntity {
@Column
private String comment;

@Column(nullable = false)
private Boolean isModified;

@Column(nullable = false)
private Integer thumpsUpCount;

public PhotoFeed(User user, String comment) {
this.user = user;
this.comment = comment;
this.isModified = false;
this.thumpsUpCount = 0;
}

public boolean isModified() {
return !getCreatedAt().isEqual(getLastModifiedAt());
return isModified;
}

public void increase() {
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/db/migration/V241128.2__add_column.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
alter table photo_feed add column is_modified boolean not null;
17 changes: 0 additions & 17 deletions src/test/java/gymmi/photoboard/domain/entity/PhotoFeedTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,6 @@

class PhotoFeedTest {

@ParameterizedTest
@CsvSource(value = {"1,true", "0,false"})
void 수정여부를_확인_한다(int plusDay, boolean isModified) {
// given
LocalDateTime now = LocalDateTime.now();
PhotoFeed photoFeed = Instancio.of(PhotoFeed.class)
.set(Select.field(PhotoFeed::getCreatedAt), now)
.set(Select.field(PhotoFeed::getLastModifiedAt), now.plusDays(plusDay))
.create();

// when
boolean result = photoFeed.isModified();

// then
assertThat(result).isEqualTo(isModified);
}

@Test
void 작성자가_아닌_경우_예외가_발생한다() {
// given
Expand Down

0 comments on commit a92e033

Please sign in to comment.