public
Clone URL: git://github.com/paulanthonywilson/yaapt-2.git
basic summary email from command line
Paul Wilson (author)
Fri Jun 27 16:13:50 -0700 2008
commit  db1118a79635b72ad87e6e30ebdc63d47414ae83
tree    16e7721fbdca64c5ba467602e6c79b9c7618d54c
parent  8e61a84dc3c6075a8aa1ef9ab3a29b9ce430c153
...
41
42
43
44
 
45
46
47
 
 
 
 
 
48
49
50
...
41
42
43
 
44
45
46
 
47
48
49
50
51
52
53
54
0
@@ -41,10 +41,14 @@ class ReleasesController < ApplicationController
0
   end
0
 
0
   def burndown_image
0
- send_data( @release.to_burndown_graph.to_blob,
0
+ send_data( @release.to_burndown_graph,
0
       :disposition => 'inline',
0
       :type => 'image/png',
0
- :filename => "my_fruity_graph.png")
0
+ :filename => "burndown.png")
0
+ end
0
+
0
+ def mail_summary
0
+ ReleaseMailer.summary
0
   end
0
 
0
 private
...
6
7
8
9
10
 
 
11
12
13
...
6
7
8
 
 
9
10
11
12
13
0
@@ -6,8 +6,8 @@ class BurndownGraph
0
     yield self if block_given?
0
   end
0
 
0
- def to_gruff
0
- g = Gruff::AllLabelLine.new(650)
0
+ def to_gruff(size=650)
0
+ g = Gruff::AllLabelLine.new(size)
0
     g.hide_dots = true
0
     g.hide_legend = true
0
     g.title = @title
...
3
4
5
 
 
 
 
 
 
6
7
8
...
11
12
13
 
 
 
14
15
16
...
21
22
23
24
 
25
26
27
28
29
30
 
31
32
33
...
3
4
5
6
7
8
9
10
11
12
13
14
...
17
18
19
20
21
22
23
24
25
...
30
31
32
 
33
34
35
36
37
38
 
39
40
41
42
0
@@ -3,6 +3,12 @@ class Release < ActiveRecord::Base
0
   has_many :release_histories, :order=>'history_date'
0
   validates_presence_of :release_date
0
 
0
+ %w(done in_progress unstarted).each do |status|
0
+ define_method "#{status}_stories" do
0
+ stories.find_all{|story| story.status == status}
0
+ end
0
+ end
0
+
0
   def description
0
     return release_date.to_s if name.blank?
0
     "#{release_date} - #{name}"
0
@@ -11,6 +17,9 @@ class Release < ActiveRecord::Base
0
   def left_todo
0
     stories.reject(&:done?).map{|story| story.estimate ? story.estimate : 0}.sum
0
   end
0
+ def total_done
0
+ stories.find_all(&:done?).map{|story| story.estimate ? story.estimate : 0}.sum
0
+ end
0
 
0
   def notify_story_change
0
     history_today = release_histories.find_by_history_date(Date::today)
0
@@ -21,13 +30,13 @@ class Release < ActiveRecord::Base
0
     end
0
   end
0
 
0
- def to_burndown_graph
0
+ def to_burndown_graph(size=650, format='png')
0
     BurndownGraph.new do |g|
0
       g.title = description
0
       g.release_date = release_date
0
       g.histories = release_histories
0
       g.start_date = start_date
0
- end.to_gruff
0
+ end.to_gruff(size).to_blob(format)
0
   end
0
 
0
   class << self
...
56
57
58
59
 
60
61
62
...
56
57
58
 
59
60
61
62
0
@@ -56,7 +56,7 @@ Rails::Initializer.run do |config|
0
   # config.active_record.observers = :cacher, :garbage_collector
0
 
0
   # Make Active Record use UTC-base instead of local time
0
- # config.active_record.default_timezone = :utc
0
+ # config.active_record.default_timezone = :utc
0
 end
0
 require 'gruff'
0
 
...
14
15
16
17
18
19
 
 
 
 
 
 
 
 
 
 
 
...
14
15
16
 
 
17
18
19
20
21
22
23
24
25
26
27
28
0
@@ -14,5 +14,14 @@ config.action_view.debug_rjs = true
0
 config.action_controller.perform_caching = false
0
 config.action_view.cache_template_extensions = false
0
 
0
-# Don't care if the mailer can't send
0
-config.action_mailer.raise_delivery_errors = false
0
\ No newline at end of file
0
+# Do care if the mailer can't send
0
+config.action_mailer.raise_delivery_errors = true
0
+
0
+config.action_mailer.smtp_settings = {
0
+:address => "localhost",
0
+:port => 25,
0
+:domain => "domain.of.sender.net"
0
+}
0
+
0
+
0
+
...
1
2
3
 
4
5
 
 
6
7
8
...
1
2
 
3
4
5
6
7
8
9
10
0
@@ -1,8 +1,10 @@
0
 ActionController::Routing::Routes.draw do |map|
0
   map.resources :stories, :member=>{:advance=>:put}, :collection=>{:unassigned=>:get}
0
- map.resources :releases, :has_many=>[:stories], :member=>{:drop_release=>:post, :burndown=>:get, :burndown_image=>:get}
0
+ map.resources :releases, :has_many=>[:stories], :member=>{:drop_release=>:post, :burndown=>:get, :burndown_image=>:get, :mail_summary=>:post}
0
   map.drop_story_unassign_release 'releases/drop_unassign_story', :controller => 'releases', :action => 'drop_unassign_release'
0
 
0
+
0
+
0
   # The priority is based upon order of creation: first created -> highest priority.
0
 
0
   # Sample of regular route:
...
117
118
119
 
 
 
 
 
 
 
 
 
 
 
 
 
 
120
121
122
...
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
0
@@ -117,6 +117,20 @@ class ReleasesControllerTest < ActionController::TestCase
0
     should_have_release_form_fields "edit_release_#{Fixtures.identify(:tea_and_biscuits)}"
0
   end
0
   
0
+ context "burndown image" do
0
+ setup do
0
+ @release = flexmock("release", :to_burndown_graph=>"my graph")
0
+ flexmock(Release).should_receive(:find).and_return(@release)
0
+ get :burndown_image, :id=>555
0
+ end
0
+
0
+ should "serve the image as an inline png" do
0
+ assert_equal "my graph", @response.body
0
+ assert_equal "image/png", @response.headers['type']
0
+ assert_equal 'inline; filename="burndown.png"', @response.headers['Content-Disposition']
0
+ end
0
+
0
+ end
0
   
0
   
0
 
...
2
3
4
5
 
6
7
8
...
2
3
4
 
5
6
7
8
0
@@ -2,7 +2,7 @@ require File.dirname(__FILE__) + '/../test_helper'
0
 
0
 class StoriesControllerTest < ActionController::TestCase
0
   NEW_STORY_PARAMS={ :title=>'A new story', :body=>'as a developer I want this test to pass', :estimate=>1}
0
- NEW_STORY_PARAMS_WITH_RELEASE=NEW_STORY_PARAMS.merge(:release_id=>Fixtures.identify(:tea_and_biscuits))
0
+ NEW_STORY_PARAMS_WITH_RELEASE=NEW_STORY_PARAMS.merge(:release_id=>Fixtures::identify(:tea_and_biscuits))
0
   
0
   
0
   context "stories with release" do
...
13
14
15
 
 
16
17
18
...
13
14
15
16
17
18
19
20
0
@@ -13,6 +13,8 @@ class BurndownGraphTest < Test::Unit::TestCase
0
     flexmock(Gruff::AllLabelLine, :new=>@gruff)
0
     @testee = BurndownGraph.new
0
   end
0
+
0
+
0
 
0
   should "have a title" do
0
     @testee.title = "hello title"
...
62
63
64
65
 
66
67
68
69
70
 
 
 
 
 
 
 
 
 
 
71
72
73
...
89
90
91
92
 
93
94
95
96
 
97
98
 
 
99
100
 
101
102
103
104
 
 
 
 
 
 
 
 
 
 
 
 
105
106
107
108
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
109
 
...
62
63
64
 
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
...
99
100
101
 
102
103
104
105
106
107
108
 
109
110
111
 
112
113
114
115
 
116
117
118
119
120
121
122
123
124
125
126
127
128
129
 
 
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
0
@@ -62,12 +62,22 @@ class ReleaseTest < ActiveSupport::TestCase
0
     should "be total of estimates of stories that are not done" do
0
       assert_equal 3, releases(:tea_and_biscuits).left_todo
0
     end
0
-
0
+
0
     should "consider nil estimate to be zero" do
0
       releases(:tea_and_biscuits).stories << Story.new
0
       assert_equal 3, releases(:tea_and_biscuits).left_todo
0
     end
0
   end
0
+ context "done" do
0
+ should "be total of estimates of stories that are done" do
0
+ assert_equal 2, releases(:tea_and_biscuits).total_done
0
+ end
0
+
0
+ should "consider nil estimate to be zero" do
0
+ releases(:tea_and_biscuits).stories << Story.new(:status=>'done')
0
+ assert_equal 2, releases(:tea_and_biscuits).total_done
0
+ end
0
+ end
0
 
0
   context "notify_story_change" do
0
     setup do
0
@@ -89,21 +99,54 @@ class ReleaseTest < ActiveSupport::TestCase
0
       assert_equal 3, today_histories.first.left_todo
0
     end
0
   end
0
-
0
+
0
   context "burndown graph" do
0
     setup do
0
       @release = releases(:tea_and_biscuits)
0
       @gruff = flexmock('gruff')
0
+ @gruff.should_receive(:to_blob).with('png').and_return('blobby')
0
       @gruff.should_ignore_missing
0
- flexmock(Gruff::AllLabelLine, :new=>@gruff)
0
+
0
+ flexmock(Gruff::AllLabelLine).should_receive(:new).with(650).and_return(@gruff)
0
     end
0
-
0
+
0
     should "be an all label line graph" do
0
       @gruff.should_receive(:title=).with(@release.description).once
0
       @gruff.should_receive(:data).with("burndown",on { |data_points| data_points.size == 30} ).once
0
- @release.to_burndown_graph
0
+ assert_equal 'blobby', @release.to_burndown_graph
0
+ end
0
+
0
+ should "be able to specify the size" do
0
+ flexmock(Gruff::AllLabelLine).should_receive(:new).with(260).and_return(@gruff).once
0
+ @release.to_burndown_graph(260)
0
+ end
0
+
0
+ should "be able to specify the format" do
0
+ @gruff.should_receive(:to_blob).with('jpeg').and_return('jpegy').once
0
+ #assert_equal 'jpegy',
0
+ @release.to_burndown_graph(650, 'jpeg')
0
     end
0
   end
0
-
0
-
0
+
0
+ context "story lists" do
0
+ setup do
0
+ @release = releases(:tea_and_biscuits)
0
+ end
0
+
0
+ should "have only done stories in done list" do
0
+ assert_equal([stories(:biscuits)], @release.done_stories)
0
+ end
0
+
0
+ should "have only unstarted stories in unstarted list" do
0
+ assert_equal([stories(:make_tea)], @release.unstarted_stories)
0
+ end
0
+
0
+ should "have only in-progress stories in in-progress list" do
0
+ assert_equal([stories(:make_coffee)], @release.in_progress_stories)
0
+ end
0
+
0
+ end
0
+
0
+
0
 end
0
+

Comments

    No one has commented yet.