Wrap comment params for flat JSON payloads (#2679)

* Wrap comment params for flat JSON payloads

The SDK sends flat JSON ({"body": "..."}) but Rails wrap_parameters
auto-detection misses :body since it's a virtual ActionText attribute,
not in Comment.attribute_names. Explicitly declare wrap_parameters so
params.expect(comment: [...]) works with both wrapped and flat payloads.

* Test comment create and update with flat JSON params
This commit is contained in:
Jeremy Daer
2026-03-09 17:02:08 -07:00
committed by GitHub
parent 23ac76555b
commit 71a1ee7031
2 changed files with 21 additions and 0 deletions
@@ -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)