Skip to content

Commit

Permalink
refactor(models/content): rename from ContentResponseModel to `Cont…
Browse files Browse the repository at this point in the history
…entDetailResponseModel`
  • Loading branch information
yoshinorin committed Dec 4, 2024
1 parent d37a3fa commit 41f6cf7
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ class ContentService[F[_]: Monad](
* @param path a content path
* @return ResponseContent instance
*/
def findByPathWithMeta(path: Path): IO[Option[ContentResponseModel]] = {
def findByPathWithMeta(path: Path): IO[Option[ContentDetailResponseModel]] = {
this.findBy(path)(findByPathWithMetaCont)
}

Expand All @@ -285,7 +285,7 @@ class ContentService[F[_]: Monad](
executer.transact(findByIdCont(id))
}

def findBy[A](data: A)(f: A => ContT[F, Option[ContentWithMeta], Option[ContentWithMeta]]): IO[Option[ContentResponseModel]] = {
def findBy[A](data: A)(f: A => ContT[F, Option[ContentWithMeta], Option[ContentWithMeta]]): IO[Option[ContentDetailResponseModel]] = {
executer.transact(f(data)).flatMap {
case None => IO(None)
case Some(x) =>
Expand All @@ -295,7 +295,7 @@ class ContentService[F[_]: Monad](

IO(
Some(
ContentResponseModel(
ContentDetailResponseModel(
id = x.id,
title = x.title,
robotsAttributes = x.robotsAttributes,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import net.yoshinorin.qualtet.domains.externalResources.ExternalResources
import net.yoshinorin.qualtet.domains.robots.Attributes
import net.yoshinorin.qualtet.domains.tags.Tag

final case class ContentResponseModel(
final case class ContentDetailResponseModel(
id: ContentId,
title: String,
robotsAttributes: Attributes,
Expand All @@ -21,8 +21,8 @@ final case class ContentResponseModel(
updatedAt: Long
)

object ContentResponseModel {
given codecResponseContent: JsonValueCodec[ContentResponseModel] = JsonCodecMaker.make(
object ContentDetailResponseModel {
given codecResponseContent: JsonValueCodec[ContentDetailResponseModel] = JsonCodecMaker.make(
CodecMakerConfig
.withRequireCollectionFields(true)
.withTransientEmpty(false)
Expand All @@ -31,5 +31,5 @@ object ContentResponseModel {
.withTransientEmpty(false)
.withTransientDefault(false)
)
given codecResponseContents: JsonValueCodec[Seq[ContentResponseModel]] = JsonCodecMaker.make
given codecResponseContents: JsonValueCodec[Seq[ContentDetailResponseModel]] = JsonCodecMaker.make
}
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ class ContentSpec extends AnyWordSpec {
""".stripMargin.replaceAll("\n", "").replaceAll(" ", "")

val json =
ContentResponseModel(
ContentDetailResponseModel(
id = ContentId("01h08dm4th59wsk81d4h96cf6b"),
title = "title",
robotsAttributes = Attributes("noarchive, noimageindex"),
Expand Down Expand Up @@ -195,7 +195,7 @@ class ContentSpec extends AnyWordSpec {

val json =
Seq(
ContentResponseModel(
ContentDetailResponseModel(
id = ContentId("01h08dm4th59wsk81d4h96cf6b"),
title = "title1",
robotsAttributes = Attributes("noarchive, noimageindex"),
Expand All @@ -220,7 +220,7 @@ class ContentSpec extends AnyWordSpec {
publishedAt = 1567814290,
updatedAt = 1567814299
),
ContentResponseModel(
ContentDetailResponseModel(
id = ContentId("01h08dm4th59wsk81d4h96cf6c"),
title = "title2",
robotsAttributes = Attributes("all"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import org.typelevel.ci.*
import net.yoshinorin.qualtet.auth.RequestToken
import net.yoshinorin.qualtet.domains.authors.AuthorResponseModel
import net.yoshinorin.qualtet.domains.Path
import net.yoshinorin.qualtet.domains.contents.{Content, ContentId, ContentRequestModel, ContentResponseModel}
import net.yoshinorin.qualtet.domains.contents.{Content, ContentDetailResponseModel, ContentId, ContentRequestModel}
import net.yoshinorin.qualtet.domains.robots.Attributes
import net.yoshinorin.qualtet.http.errors.ResponseProblemDetails
import net.yoshinorin.qualtet.fixture.Fixture.*
Expand Down Expand Up @@ -455,7 +455,7 @@ class ContentRouteV1Spec extends AnyWordSpec {
assert(response.status === Ok)
assert(response.contentType.get === `Content-Type`(MediaType.application.json))

val maybeContent = unsafeDecode[ContentResponseModel](response)
val maybeContent = unsafeDecode[ContentDetailResponseModel](response)
assert(maybeContent.authorName === validAuthor.displayName.toString().toLowerCase())
assert(maybeContent.content === "<p>this is a html ContentRouteSpec2<p>")
assert(maybeContent.description === "this is a html ContentRouteSpec2")
Expand Down

0 comments on commit 41f6cf7

Please sign in to comment.