File tree Expand file tree Collapse file tree
test/lib/code_corps_web/controllers Expand file tree Collapse file tree Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments