diff --git a/app/controllers/cards/comments_controller.rb b/app/controllers/cards/comments_controller.rb index 6a377bc2c..7aed33c8c 100644 --- a/app/controllers/cards/comments_controller.rb +++ b/app/controllers/cards/comments_controller.rb @@ -1,4 +1,5 @@ class Cards::CommentsController < ApplicationController + wrap_parameters :comment, include: %i[ body created_at ] include CardScoped before_action :set_comment, only: %i[ show edit update destroy ] diff --git a/test/controllers/cards/comments_controller_test.rb b/test/controllers/cards/comments_controller_test.rb index eebd62a9c..be5831e39 100644 --- a/test/controllers/cards/comments_controller_test.rb +++ b/test/controllers/cards/comments_controller_test.rb @@ -84,6 +84,26 @@ class Cards::CommentsControllerTest < ActionDispatch::IntegrationTest assert_equal card_comment_url(comment.card, comment), @response.parsed_body["url"] end + test "create as JSON with flat params" do + card = cards(:logo) + + assert_difference -> { card.comments.count }, +1 do + post card_comments_path(card), params: { body: "Flat comment" }, as: :json + end + + assert_response :created + assert_equal "Flat comment", Comment.last.body.to_plain_text + end + + test "update as JSON with flat params" do + comment = comments(:logo_agreement_kevin) + + put card_comment_path(cards(:logo), comment), params: { body: "Flat update" }, as: :json + + assert_response :success + assert_equal "Flat update", comment.reload.body.to_plain_text + end + test "update as JSON" do comment = comments(:logo_agreement_kevin)