From 2fc1dfdf92909480a191acb65291614851b0ae4f Mon Sep 17 00:00:00 2001 From: Tim Pope Date: Wed, 10 Dec 2008 17:50:06 -0500 Subject: [PATCH] Finishing a chore or release marks it accepted --- lib/pickler/feature.rb | 10 +++++++--- lib/pickler/tracker/story.rb | 16 +++++++++++++++- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/lib/pickler/feature.rb b/lib/pickler/feature.rb index e3d447b..c4a891c 100644 --- a/lib/pickler/feature.rb +++ b/lib/pickler/feature.rb @@ -66,9 +66,13 @@ def push end def finish - story.current_state = "finished" unless story.complete? - story.to_s = local_body if filename - story.save + if filename + story.finish + story.to_s = local_body + story.save + else + story.finish! + end end def id diff --git a/lib/pickler/tracker/story.rb b/lib/pickler/tracker/story.rb index 0b01a61..d29e66f 100644 --- a/lib/pickler/tracker/story.rb +++ b/lib/pickler/tracker/story.rb @@ -25,7 +25,7 @@ def transition!(state) raise Pickler::Tracker::Error, "Invalid state #{state}", caller unless STATES.include?(state) self.current_state = state if id - xml = "#{state}" + xml = "#{state}" error = tracker.request_xml(:put, resource_url, xml).fetch("errors",{})["error"] || true else error = save @@ -33,6 +33,20 @@ def transition!(state) raise Pickler::Tracker::Error, Array(error).join("\n"), caller unless error == true end + def finish + case story_type + when "bug", "feature" + self.current_state = "finished" unless complete? + when "chore", "release" + self.current_state = "accepted" + end + current_state + end + + def finish! + transition!(finish) + end + def backlog?(as_of = Date.today) iteration && iteration.start >= as_of end