More tests
This commit is contained in:
@@ -21,17 +21,23 @@ defmodule Eventos.Events.Comment do
|
||||
belongs_to(:in_reply_to_comment, Comment, foreign_key: :in_reply_to_comment_id)
|
||||
belongs_to(:origin_comment, Comment, foreign_key: :origin_comment_id)
|
||||
|
||||
timestamps()
|
||||
timestamps(type: :utc_datetime)
|
||||
end
|
||||
|
||||
@doc false
|
||||
def changeset(comment, attrs) do
|
||||
uuid = Ecto.UUID.generate()
|
||||
|
||||
# TODO : really change me right away
|
||||
url =
|
||||
if Map.has_key?(attrs, "url"),
|
||||
do: attrs["url"],
|
||||
else: "#{EventosWeb.Endpoint.url()}/comments/#{uuid}"
|
||||
|
||||
comment
|
||||
|> cast(attrs, [:url, :text, :actor_id, :event_id, :in_reply_to_comment_id, :attributed_to_id])
|
||||
|> validate_required([:text, :actor_id])
|
||||
|> put_change(:uuid, uuid)
|
||||
|> put_change(:url, "#{EventosWeb.Endpoint.url()}/comments/#{uuid}")
|
||||
|> put_change(:url, url)
|
||||
|> validate_required([:text, :actor_id, :url])
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user