From a14bb728898e7235035b02217c853b8b3029c3d5 Mon Sep 17 00:00:00 2001 From: Alexander Graul Date: Thu, 19 Jul 2018 12:23:46 +0200 Subject: [PATCH 1/3] add board setup to trollolo scrum end_sprint Add the missing board setup that gets passed to Scrum::SprintCleaner --- lib/cli/scrum.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/cli/scrum.rb b/lib/cli/scrum.rb index 5788604..40a13b2 100644 --- a/lib/cli/scrum.rb +++ b/lib/cli/scrum.rb @@ -46,9 +46,11 @@ def end_sprint CliSettings.process_global_options options CliSettings.require_trello_credentials - s = Scrum::SprintCleaner.new(CliSettings.settings) - s.cleanup(CliSettings.board_id(options['board-id']), - CliSettings.board_id(options['target-board-id'])) + boards = Scrum::Boards.new(CliSettings.settings.scrum) + cleaner = Scrum::SprintCleaner.new(CliSettings.settings) + cleaner.setup_boards(sprint_board: boards.sprint_board(CliSettings.board_from_id(options['board-id'])), + target_board: CliSettings.board_from_id(options['target-board-id'])) + cleaner.cleanup end desc 'start', 'Move the planning backlog to the sprint board' From b34d14a4b3e1f9debcf6d2006b1d30ab24ffbc11 Mon Sep 17 00:00:00 2001 From: Alexander Graul Date: Thu, 19 Jul 2018 14:50:25 +0200 Subject: [PATCH 2/3] add --burndown-update flag to end-sprint Previously, new burndown data was always generated as part of `trollolo scrum end-sprint`. Now it requires an explicit flag: trollolo scrum end-sprint --burndown-update The name for this flag is named after `trollolo burndown update`. --- lib/cli/scrum.rb | 3 ++- lib/scrum/sprint_cleaner.rb | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/cli/scrum.rb b/lib/cli/scrum.rb index 40a13b2..516bc22 100644 --- a/lib/cli/scrum.rb +++ b/lib/cli/scrum.rb @@ -42,6 +42,7 @@ def prioritize EOT option 'board-id', desc: 'Id of the board', required: true option 'target-board-id', desc: 'Id of the target board', required: true + option 'burndown-update', desc: 'Generate new burndown data', type: :boolean, default: false def end_sprint CliSettings.process_global_options options CliSettings.require_trello_credentials @@ -50,7 +51,7 @@ def end_sprint cleaner = Scrum::SprintCleaner.new(CliSettings.settings) cleaner.setup_boards(sprint_board: boards.sprint_board(CliSettings.board_from_id(options['board-id'])), target_board: CliSettings.board_from_id(options['target-board-id'])) - cleaner.cleanup + cleaner.cleanup(run_burndown: options['burndown-update']) end desc 'start', 'Move the planning backlog to the sprint board' diff --git a/lib/scrum/sprint_cleaner.rb b/lib/scrum/sprint_cleaner.rb index 4d9c2a4..6b6e968 100644 --- a/lib/scrum/sprint_cleaner.rb +++ b/lib/scrum/sprint_cleaner.rb @@ -2,10 +2,10 @@ module Scrum class SprintCleaner < TrelloService include BoardLocator - def cleanup(set_last_sprint_label: false) + def cleanup(set_last_sprint_label: false, run_burndown: false) load - gen_burndown + gen_burndown if run_burndown move_cards(@board.backlog_list, set_last_sprint_label) move_cards(@board.doing_list, set_last_sprint_label) if @board.doing_list @@ -64,7 +64,7 @@ def gen_burndown chart = BurndownChart.new(@settings) begin chart.update({}) - puts 'New burndown data was generated automatically.' + puts "Updated data for sprint #{chart.sprint}" rescue TrolloloError => e if e.message =~ /(burndown-data-)\d*.yaml' (not found)/ puts e.message + '. Skipping automatic burndown generation.' From 5295d0c382625e07cf9b0b8bfa247ff8110f0501 Mon Sep 17 00:00:00 2001 From: Alexander Graul Date: Thu, 19 Jul 2018 15:07:51 +0200 Subject: [PATCH 3/3] adapt tests to run_burndown parameter in cleanup() test both the new default (no burndown data generation) and the optional cleanup(run_burndown: true) --- spec/unit/scrum/sprint_cleaner_spec.rb | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/spec/unit/scrum/sprint_cleaner_spec.rb b/spec/unit/scrum/sprint_cleaner_spec.rb index f9bb04a..4e03222 100644 --- a/spec/unit/scrum/sprint_cleaner_spec.rb +++ b/spec/unit/scrum/sprint_cleaner_spec.rb @@ -37,7 +37,7 @@ end it 'moves remaining cards to target board' do - expect(STDOUT).to receive(:puts).exactly(4).times + expect(STDOUT).to receive(:puts).exactly(3).times expect(old_story_card).to receive(:move_to_board).with(target_board, ready_for_estimation).exactly(3).times expect(old_story_card).to receive(:add_label).exactly(3).times sprint_cleaner.cleanup(set_last_sprint_label: true) @@ -45,7 +45,7 @@ end it 'moves remaining cards to target board' do - expect(STDOUT).to receive(:puts).exactly(4).times + expect(STDOUT).to receive(:puts).exactly(3).times expect(old_story_card).to receive(:move_to_board).with(target_board, ready_for_estimation).exactly(3).times sprint_cleaner.cleanup end @@ -70,11 +70,18 @@ allow_any_instance_of(BurndownChart).to receive(:update) end - it 'generates new burndown data' do + it 'does not generate new burndown data per default' do expect(old_story_card).to receive(:move_to_board).with(target_board, ready_for_estimation).exactly(3).times expect do sprint_cleaner.cleanup - end.to output(/^(New burndown data was generated automatically)/).to_stdout + end.not_to output(/^(Update data for sprint 1)/).to_stdout + end + + it 'generates new burndown data when run_burndown parameter is true' do + expect(old_story_card).to receive(:move_to_board).with(target_board, ready_for_estimation).exactly(3).times + expect do + sprint_cleaner.cleanup(run_burndown: true) + end.to output(/^(Update data for sprint 1)*/).to_stdout end end