From 5059509f3f0d7371931d6e0605754d1743ab5656 Mon Sep 17 00:00:00 2001 From: Chrissie Date: Thu, 27 Aug 2015 17:02:50 -0500 Subject: [PATCH] Add a checklist with an initial todo upon card creation --- lib/github_to_trello/trello_gateway.rb | 12 ++++++++++-- spec/trello_gateway_spec.rb | 9 +++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/lib/github_to_trello/trello_gateway.rb b/lib/github_to_trello/trello_gateway.rb index 2356c85..2457d1a 100644 --- a/lib/github_to_trello/trello_gateway.rb +++ b/lib/github_to_trello/trello_gateway.rb @@ -33,11 +33,19 @@ def _existing_card?(issue) end def _create_card(issue) - Trello::Card.create( + card = Trello::Card.create( :name => issue.title, :list_id => @list.id, - :desc => issue.body + "\n" + issue.html_url + "\n" + issue.updated_at.to_s + :desc => issue.body + "\n" + issue.html_url + "\n" + issue.updated_at.to_s, ) + _add_checklist_to(card) + card + end + + def _add_checklist_to(card) + checklist = Trello::Checklist.create(:name => "Todo", :board_id => @board.id) + checklist.add_item("Initial Response") + card.add_checklist(checklist) end def _list_contains_issue?(list, issue) diff --git a/spec/trello_gateway_spec.rb b/spec/trello_gateway_spec.rb index 11cda68..08c0847 100644 --- a/spec/trello_gateway_spec.rb +++ b/spec/trello_gateway_spec.rb @@ -96,6 +96,15 @@ expect(card.list.name).to eq("django_blog") end + it "includes a checklist with item for initial response when creating cards" do + card = @gateway.create_or_update_card(@issue) + expect(card.checklists.length).to eq 1 + + checklist = card.checklists.first + expect(checklist.items.length).to eq 1 + expect(checklist.items.first.name).to eq "Initial Response" + end + it "does not add a duplicate card if card exits in list already" do card = @gateway.create_or_update_card(@issue) card = @gateway.create_or_update_card(@issue)