Skip to content

Commit

Permalink
Add a checklist with an initial todo upon card creation
Browse files Browse the repository at this point in the history
  • Loading branch information
chrissiedunham committed Aug 27, 2015
1 parent 95425aa commit 5059509
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib/github_to_trello/trello_gateway.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 9 additions & 0 deletions spec/trello_gateway_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 5059509

Please sign in to comment.