The backlog items on the sprint are grouped by whether they were
accepted, rejected or abstained from in the vote. If they were accepted
then the developer's estimate is included.
Signed-off-by: Darryl L. Pierce <mcpierce(a)gmail.com>
---
app/controllers/sprints_controller.rb | 2 ++
app/models/backlog_item_vote.rb | 1 +
app/models/user_mailer.rb | 10 ++++++++++
app/views/user_mailer/votes_cast.html.erb | 11 +++++++++++
doc/ChangeLog | 1 +
test/functional/sprints_controller_test.rb | 10 ++++++++++
6 files changed, 35 insertions(+), 0 deletions(-)
create mode 100644 app/views/user_mailer/votes_cast.html.erb
diff --git a/app/controllers/sprints_controller.rb
b/app/controllers/sprints_controller.rb
index 4c3d739..3aac6a2 100644
--- a/app/controllers/sprints_controller.rb
+++ b/app/controllers/sprints_controller.rb
@@ -176,6 +176,8 @@ class SprintsController < ApplicationController
@user_votes.each do |vote|
vote.save!
end
+ # send an email to the team lead
+ UserMailer.deliver_votes_cast(@sprint, @user, @user_votes)
respond_to do |format|
flash[:message] = "Your votes have been cast."
format.html {redirect_to sprint_path(@sprint)}
diff --git a/app/models/backlog_item_vote.rb b/app/models/backlog_item_vote.rb
index 7ecd5e5..17a4582 100644
--- a/app/models/backlog_item_vote.rb
+++ b/app/models/backlog_item_vote.rb
@@ -37,6 +37,7 @@ class BacklogItemVote < ActiveRecord::Base
NAK = -1
VOTES = {"Abstain" => ABSTAIN, "Accept" => ACK,
"Reject" => NAK}
+ VOTE_TEXT = {ABSTAIN => "Abstrained", ACK => "Accepted", NAK
=> "Rejected"}
def validate
errors.add("estimated_hours", "An accepted item must have an hours
estimate.") if (vote == ACK) && (estimated_hours <= 0)
diff --git a/app/models/user_mailer.rb b/app/models/user_mailer.rb
index 18afd18..4e1acef 100644
--- a/app/models/user_mailer.rb
+++ b/app/models/user_mailer.rb
@@ -73,6 +73,16 @@ class UserMailer < ActionMailer::Base
body :role => role
end
+ # Sends an email to the sprint team lead when a developer has cast votes
+ # on backlog items for a proposed sprint.
+ def votes_cast(sprint, developer, votes)
+ recipients sprint.team_lead.email
+ cc developer.email
+ from MAIL_CONFIG[:from]
+ subject "Votes cast: #{sprint.title}"
+ body :sprint => sprint, :developer => developer, :votes => votes
+ end
+
# Sends an email to a user letting him know his daily activities.
def daily_updates(user, cc_list, open_items, completed_items, task_performed)
recipients user.email
diff --git a/app/views/user_mailer/votes_cast.html.erb
b/app/views/user_mailer/votes_cast.html.erb
new file mode 100644
index 0000000..39b3b16
--- /dev/null
+++ b/app/views/user_mailer/votes_cast.html.erb
@@ -0,0 +1,11 @@
+The following votes were cast by <%= @developer.display_name %> <<%=
@developer.email %>>:
+
+<% @votes.sort! { |x, y| x.vote <=> y.vote } %>
+<% last_vote_type = nil %>
+<% @votes.each do |vote| %>
+ <% if last_vote_type != vote.vote %>
+<%= BacklogItemVote::VOTE_TEXT[vote.vote] %>
+ <% last_vote_type = vote.vote %>
+ <% end %>
+<%= vote.backlog_item.user_story.title %> <% if vote.vote ==
BacklogItemVote::ACK %><%= "(#{vote.estimated_hours} hours)" %><%
end %>
+<% end %>
diff --git a/doc/ChangeLog b/doc/ChangeLog
index 2802c71..adac356 100644
--- a/doc/ChangeLog
+++ b/doc/ChangeLog
@@ -12,6 +12,7 @@ Change Log (0.3.0):
* #168 - Users can post comments for epic stories.
* #169 - Comments on epics are shown on the details page.
* #170 - Users are sent an email notifying them of replies to their posts.
+ * #171 - When a developer votes on a backlog, the team lead is sent an email.
* #173 - Backlog items can be dropped from an active sprint.
* #174 - Deferred backlog items can be re-added to the active sprint.
* #175 - When viewing an unapproved project's product list, the sidebar is
misplaced. (BUG)
diff --git a/test/functional/sprints_controller_test.rb
b/test/functional/sprints_controller_test.rb
index 505e7b7..80894bf 100644
--- a/test/functional/sprints_controller_test.rb
+++ b/test/functional/sprints_controller_test.rb
@@ -89,6 +89,13 @@ class SprintsControllerTest < ActionController::TestCase
@selected = [
@user_story.id
]
+
+ ActionMailer::Base.delivery_method = :test
+ ActionMailer::Base.perform_deliveries = true
+ ActionMailer::Base.deliveries = []
+
+ @emails = ActionMailer::Base.deliveries
+ @emails.clear
end
# Ensures that a list of all sprints is viewable.
@@ -699,5 +706,8 @@ class SprintsControllerTest < ActionController::TestCase
assert_redirected_to sprint_path(@proposed_sprint)
assert_equal count + 1, BacklogItemVote.for_sprint((a)proposed_sprint).size, "A
new vote should have been cast."
+ email = @emails.first
+ assert email, "An email should have been sent to the team lead."
+ assert_equal @proposed_sprint.team_lead.email, email.to[0], "Email was not sent
to the correct person."
end
end
--
1.6.2.5
Show replies by date