Skip to content

Commit c4ca822

Browse files
committed
Reinstate the markdown restrictions on comments
1 parent bf83fd0 commit c4ca822

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

lib/code_corps/model/comment.ex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ defmodule CodeCorps.Comment do
2626
def changeset(struct, params \\ %{}) do
2727
struct
2828
|> cast(params, [:markdown])
29+
|> validate_required([:markdown])
2930
|> MarkdownRendererService.render_markdown_to_html(:markdown, :body)
3031
end
3132

test/lib/code_corps_web/controllers/comment_controller_test.exs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,14 @@ defmodule CodeCorpsWeb.CommentControllerTest do
9898
assert_received {:track, ^user_id, "Edited Comment", ^tracking_properties}
9999
end
100100

101+
@tag :authenticated
102+
test "does not update chosen resource and renders errors when data is invalid", %{conn: conn, current_user: current_user} do
103+
comment = insert(:comment, user: current_user)
104+
attrs = @invalid_attrs |> Map.merge(%{user: current_user})
105+
json = conn |> request_update(comment, attrs) |> json_response(422)
106+
assert json["errors"] != %{}
107+
end
108+
101109
test "does not update resource and renders 401 when not authenticated", %{conn: conn} do
102110
assert conn |> request_update(@valid_attrs) |> json_response(401)
103111
end

0 commit comments

Comments
 (0)