API: Support created_at for API card and comment creation (#2056)

* Add support to set `created_at`

Discussed in
https://github.com/basecamp/fizzy/pull/1766#issuecomment-3637846074,
this allows users to import cards from another system with entries from
the past. For instance I'm importing all our Github issues (including
the closed onces) to Fizzy.

* Iron out published state tracking

---------

Co-authored-by: Jeremy Daer <jeremy@37signals.com>
This commit is contained in:
Jankees van Woezik
2025-12-11 04:57:38 +01:00
committed by GitHub
parent 90452a4236
commit 477b4d65f2
6 changed files with 37 additions and 23 deletions
+13
View File
@@ -160,6 +160,19 @@ class CardsControllerTest < ActionDispatch::IntegrationTest
assert_equal [ tags(:mobile), tags(:web) ].sort, card.tags.sort
end
test "create as JSON with custom created_at" do
custom_time = Time.utc(2024, 1, 15, 10, 30, 0)
assert_difference -> { Card.count }, +1 do
post board_cards_path(boards(:writebook)),
params: { card: { title: "Backdated card", created_at: custom_time } },
as: :json
end
assert_response :created
assert_equal custom_time, Card.last.created_at
end
test "update as JSON" do
card = cards(:logo)
put card_path(card, format: :json), params: { card: { title: "Update test" } }