Skip to content

Commit 748be87

Browse files
committed
Include card description and tags
1 parent bd5b46b commit 748be87

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

app/views/cards/_card.json.jbuilder

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
json.cache! [ card, card.column&.color ] do
22
json.(card, :id, :title, :status)
3+
json.description card.description.to_plain_text
4+
json.description_html card.description.to_s
35
json.image_url card.image.presence && url_for(card.image)
46

7+
json.tags card.tags.pluck(:title).sort
8+
59
json.golden card.golden?
610
json.last_active_at card.last_active_at.utc
711
json.created_at card.created_at.utc

test/controllers/api_test.rb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,17 @@ class ApiTest < ActionDispatch::IntegrationTest
4141
end
4242

4343
test "create card" do
44-
post board_cards_path(boards(:writebook), format: :json), params: { card: { title: "My new card" } }, env: @davids_bearer_token
44+
post board_cards_path(boards(:writebook), format: :json),
45+
params: { card: { title: "My new card", description: "Big if true", tag_ids: [ tags(:web).id, tags(:mobile).id ] } },
46+
env: @davids_bearer_token
47+
4548
assert_equal card_path(Card.last, format: :json), @response.headers["Location"]
4649

47-
get card_path(Card.last, format: :json), env: @davids_bearer_token
50+
new_card = Card.last
51+
get card_path(new_card, format: :json), env: @davids_bearer_token
4852
assert_equal "My new card", @response.parsed_body["title"]
53+
assert_equal "Big if true", @response.parsed_body["description"]
54+
assert_equal [ tags(:web).title, tags(:mobile).title ].sort, @response.parsed_body["tags"]
4955
end
5056

5157
test "get tags" do

0 commit comments

Comments
 (0)