Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/code_corps/model/comment.ex
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ defmodule CodeCorps.Comment do
def changeset(struct, params \\ %{}) do
struct
|> cast(params, [:markdown])
|> validate_required([:markdown])
|> MarkdownRendererService.render_markdown_to_html(:markdown, :body)
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,14 @@ defmodule CodeCorpsWeb.CommentControllerTest do
assert_received {:track, ^user_id, "Edited Comment", ^tracking_properties}
end

@tag :authenticated
test "does not update chosen resource and renders errors when data is invalid", %{conn: conn, current_user: current_user} do
comment = insert(:comment, user: current_user)
attrs = @invalid_attrs |> Map.merge(%{user: current_user})
json = conn |> request_update(comment, attrs) |> json_response(422)
assert json["errors"] != %{}
end

test "does not update resource and renders 401 when not authenticated", %{conn: conn} do
assert conn |> request_update(@valid_attrs) |> json_response(401)
end
Expand Down